[PATCH] D60247: Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added subscribers: llvm-commits, arphaman.
Herald added a project: LLVM.

Requires making the llvm::MemoryBuffer* stored by SourceManager const, which in 
turn requires making the accessors for that return const llvm::MemoryBuffer*s 
and updating all call sites.

The original motivation for this was to use it and fix the TODO in 
CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag version of 
createFileID, and since llvm::SourceMgr* hands out a const llvm::MemoryBuffer* 
this is required. I'm not sure if fixing the TODO this way actually works, but 
this seems like a good change on its own anyways.

No intended behavior change.


https://reviews.llvm.org/D60247

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/lib/StaticAnalyzer/Core/IssueHash.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Support/MemoryBuffer.h

Index: llvm/include/llvm/Support/MemoryBuffer.h
===
--- llvm/include/llvm/Support/MemoryBuffer.h
+++ llvm/include/llvm/Support/MemoryBuffer.h
@@ -264,7 +264,7 @@
 
 public:
   MemoryBufferRef() = default;
-  MemoryBufferRef(MemoryBuffer& Buffer)
+  MemoryBufferRef(const MemoryBuffer& Buffer)
   : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
   MemoryBufferRef(StringRef Buffer, StringRef Identifier)
   : Buffer(Buffer), Identifier(Identifier) {}
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -4228,7 +4228,7 @@
   const SourceManager  = cxtu::getASTUnit(TU)->getSourceManager();
   FileID fid = SM.translateFile(static_cast(file));
   bool Invalid = true;
-  llvm::MemoryBuffer *buf = SM.getBuffer(fid, );
+  const llvm::MemoryBuffer *buf = SM.getBuffer(fid, );
   if (Invalid) {
 if (size)
   *size = 0;
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -102,7 +102,8 @@
 unsigned LocColumn =
 SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
 FileID FID = SM.getFileID(Loc);
-llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+const llvm::MemoryBuffer *Buffer =
+SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
 
 assert(LocData >= Buffer->getBufferStart() &&
LocData < Buffer->getBufferEnd());
Index: clang/lib/StaticAnalyzer/Core/IssueHash.cpp
===
--- clang/lib/StaticAnalyzer/Core/IssueHash.cpp
+++ clang/lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -120,7 +120,7 @@
   return "";
 }
 
-static StringRef GetNthLineOfFile(llvm::MemoryBuffer *Buffer, int Line) {
+static StringRef GetNthLineOfFile(const llvm::MemoryBuffer *Buffer, int Line) {
   if (!Buffer)
 return "";
 
@@ -144,7 +144,7 @@
 col++;
   SourceLocation StartOfLine =
   SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col);
-  llvm::MemoryBuffer *Buffer =
+  const llvm::MemoryBuffer *Buffer =
   SM.getBuffer(SM.getFileID(StartOfLine), StartOfLine);
   if (!Buffer)
 return {};
Index: clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -1140,7 +1140,7 @@
   }
 
   bool Invalid = false;
-  llvm::MemoryBuffer *BF =
+  const llvm::MemoryBuffer *BF =
   Mgr.getSourceManager().getBuffer(SLInfo.first, SL, );
   if (Invalid)
 return;
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -377,7 +377,7 @@
   PrecompiledPreamble::PreambleFileHash::createForFile(File->getSize(),
ModTime);
 } else {
-  llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File);
+  const llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File);
   FilesInPreamble[File->getName()] =
   PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(Buffer);
 }
Index: 

[PATCH] D59987: Add support for detection of devtoolset-8

2019-04-03 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Do you have commit access?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59987/new/

https://reviews.llvm.org/D59987



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


[libunwind] r357671 - [libunwind] Export the weak alias in Mach-O

2019-04-03 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Apr  3 20:36:35 2019
New Revision: 357671

URL: http://llvm.org/viewvc/llvm-project?rev=357671=rev
Log:
[libunwind] Export the weak alias in Mach-O

This is not necessary for ELF since .globl and .weak are mutually
exclusive, but is necessary for Mach-O otherwise the symbol isn't
visible externally.

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

Modified:
libunwind/trunk/src/assembly.h

Modified: libunwind/trunk/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=357671=357670=357671=diff
==
--- libunwind/trunk/src/assembly.h (original)
+++ libunwind/trunk/src/assembly.h Wed Apr  3 20:36:35 2019
@@ -47,6 +47,7 @@
 #define HIDDEN_SYMBOL(name) .private_extern name
 #define WEAK_SYMBOL(name) .weak_reference name
 #define WEAK_ALIAS(name, aliasname)
\
+  .globl SYMBOL_NAME(aliasname) SEPARATOR  
\
   WEAK_SYMBOL(aliasname) SEPARATOR 
\
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 


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


[PATCH] D60120: check-clang-tools: Actually build and run XPC test

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60120/new/

https://reviews.llvm.org/D60120



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:18
+
+AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
+} // namespace ast_matchers

aaron.ballman wrote:
> hintonda wrote:
> > @aaron.ballman:  This matcher seems genuinely useful.  What do you think 
> > about moving it to ASTMatchers.h? 
> I think that adding something like this might be a good idea. We don't have 
> any notion of source locations in the AST matching syntax currently, and I'm 
> not certain whether that's a good thing or not here. I'm mildly uncomfortable 
> that this matcher operates on an `Expr` but then internally uses a source 
> location from that expression and I wonder if we would rather introduce 
> source location matching. For instance, what if the user cares about the 
> difference between `getExprLoc()` and `getBeginLoc()` for some reason?
Well, you can attach it to whatever you want, so I'm not sure that's a problem. 
 Alternatively, you have to check each location yourself.  In my case, that was 
multiple places, so putting it in the matcher cleaned up the code.

I need to verify it, but it seems that it triggered when any macros were in the 
range, but I need to look closer into that to understand the behavior.   I'll 
check it out and get back to you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

hintonda wrote:
> aaron.ballman wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > hintonda wrote:
> > > > > aaron.ballman wrote:
> > > > > > This diagnostic doesn't tell the user what they've done wrong with 
> > > > > > the code or why this is a better choice.
> > > > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for a 
> > > > > suggestion.  
> > > > Do you have any evidence that this situation happens in practice? I 
> > > > kind of feel like this entire branch could be eliminated from this 
> > > > patch unless it actually catches problems that happen.
> > > Yes, here are a few from clang/lib -- let me know if you think it's worth 
> > > it or not to keep this:
> > > 
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 305293
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > > Length: 93
> > > Offset: 305293
> > > ReplacementText: 
> > > dyn_cast_or_null(Name.getAsTemplateDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 153442
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > > Length: 92
> > > Offset: 153442
> > > ReplacementText: 
> > > dyn_cast_or_null(Template.getAsTemplateDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 97556
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > >   Message: method 'getMethodDecl' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > > Length: 68
> > > Offset: 97556
> > > ReplacementText: 
> > > dyn_cast_or_null(MCE->getMethodDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 301950
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > >   Message: method 'get' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > > Length: 49
> > > Offset: 301950
> > > ReplacementText: dyn_cast_or_null(CurInit.get())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 14335
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > >   Message: method 'operator bool' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > Length: 57
> > > Offset: 14335
> > > ReplacementText: dyn_cast_or_null(B->getTerminator())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 15997
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > >   Message: method 'operator bool' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > Length: 55
> > > Offset: 15997
> > > ReplacementText: dyn_cast_or_null(B.getTerminator())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 9492
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > >   Message: method 'sexpr' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > > Length: 39
> > > Offset: 9492
> > > ReplacementText: dyn_cast_or_null(sexpr())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 9572
> > >   FilePath: 
> > > 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-03 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added a comment.

Dear reviewers, any comments?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59744/new/

https://reviews.llvm.org/D59744



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

aaron.ballman wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > hintonda wrote:
> > > > aaron.ballman wrote:
> > > > > This diagnostic doesn't tell the user what they've done wrong with 
> > > > > the code or why this is a better choice.
> > > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for a 
> > > > suggestion.  
> > > Do you have any evidence that this situation happens in practice? I kind 
> > > of feel like this entire branch could be eliminated from this patch 
> > > unless it actually catches problems that happen.
> > Yes, here are a few from clang/lib -- let me know if you think it's worth 
> > it or not to keep this:
> > 
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 305293
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> >   Message: method 'getAsTemplateDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > Length: 93
> > Offset: 305293
> > ReplacementText: 
> > dyn_cast_or_null(Name.getAsTemplateDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 153442
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> >   Message: method 'getAsTemplateDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > Length: 92
> > Offset: 153442
> > ReplacementText: 
> > dyn_cast_or_null(Template.getAsTemplateDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 97556
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> >   Message: method 'getMethodDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > Length: 68
> > Offset: 97556
> > ReplacementText: 
> > dyn_cast_or_null(MCE->getMethodDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 301950
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> >   Message: method 'get' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > Length: 49
> > Offset: 301950
> > ReplacementText: dyn_cast_or_null(CurInit.get())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 14335
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> >   Message: method 'operator bool' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > Length: 57
> > Offset: 14335
> > ReplacementText: dyn_cast_or_null(B->getTerminator())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 15997
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> >   Message: method 'operator bool' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > Length: 55
> > Offset: 15997
> > ReplacementText: dyn_cast_or_null(B.getTerminator())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 9492
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> >   Message: method 'sexpr' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > Length: 39
> > Offset: 9492
> > ReplacementText: dyn_cast_or_null(sexpr())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 9572
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> >   Message: method 'sexpr' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > 

r357667 - Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)'

2019-04-03 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Apr  3 19:27:57 2019
New Revision: 357667

URL: http://llvm.org/viewvc/llvm-project?rev=357667=rev
Log:
Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink 
function calls without used results (PR41259)'

This revision causes tests to fail under ASAN. Since the cause of the failures
is not clear (could be ASAN, could be a Clang bug, could be a bug in this
revision), the safest course of action seems to be to revert while 
investigating.


Modified:
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m

Modified: cfe/trunk/test/CodeGenCXX/nrvo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nrvo.cpp?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenCXX/nrvo.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/nrvo.cpp Wed Apr  3 19:27:57 2019
@@ -60,6 +60,7 @@ X test2(bool B) {
   // CHECK-NEXT: call void @llvm.lifetime.start
   // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev
   // CHECK: call {{.*}} @_ZN1XC1ERKS_
+  // CHECK: call {{.*}} @_ZN1XC1ERKS_
   // CHECK: call {{.*}} @_ZN1XD1Ev
   // CHECK-NEXT: call void @llvm.lifetime.end
   // CHECK: call {{.*}} @_ZN1XD1Ev

Modified: cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp Wed Apr  3 19:27:57 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -o - -emit-llvm -O1 \
-// RUN: -fexceptions -fcxx-exceptions -mllvm 
-simplifycfg-sink-common=false | FileCheck %s
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
 //
 // We should emit lifetime.ends for these temporaries in both the 'exception'
 // and 'normal' paths in functions.

Modified: cfe/trunk/test/CodeGenObjC/exceptions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions.m?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions.m Wed Apr  3 19:27:57 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -mllvm 
-simplifycfg-sink-common=false -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -O2 -o - %s | 
FileCheck %s
 //
 //  [irgen] [eh] Exception code built with clang 
(x86_64) crashes
 


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


[PATCH] D59923: [Driver] Simplify -g level computation and its interaction with -gsplit-dwarf

2019-04-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59923/new/

https://reviews.llvm.org/D59923



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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Good catch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60238/new/

https://reviews.llvm.org/D60238



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD357658: [codeview] Remove Type member from CVRecord 
(authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60018?vs=193526=193633#toc

Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60018/new/

https://reviews.llvm.org/D60018

Files:
  COFF/PDB.cpp


Index: COFF/PDB.cpp
===
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -759,7 +759,7 @@
   if (Kind == SymbolKind::S_GPROC32_ID || Kind == SymbolKind::S_LPROC32_ID) {
 SmallVector Refs;
 auto Content = RecordData.drop_front(sizeof(RecordPrefix));
-CVSymbol Sym(Kind, RecordData);
+CVSymbol Sym(RecordData);
 discoverTypeIndicesInSymbol(Sym, Refs);
 assert(Refs.size() == 1);
 assert(Refs.front().Count == 1);
@@ -959,7 +959,7 @@
 MutableArrayRef RecordBytes;
 if (NeedsRealignment) {
   RecordBytes = copyAndAlignSymbol(Sym, AlignedSymbolMem);
-  Sym = CVSymbol(Sym.kind(), RecordBytes);
+  Sym = CVSymbol(RecordBytes);
 } else {
   // Otherwise, we can actually mutate the symbol directly, since we
   // copied it to apply relocations.
@@ -983,7 +983,7 @@
 // An object file may have S_xxx_ID symbols, but these get converted to
 // "real" symbols in a PDB.
 translateIdSymbols(RecordBytes, TMerger.getIDTable());
-Sym = CVSymbol(symbolKind(RecordBytes), RecordBytes);
+Sym = CVSymbol(RecordBytes);
 
 // If this record refers to an offset in the object file's string 
table,
 // add that item to the global PDB string table and re-write the index.


Index: COFF/PDB.cpp
===
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -759,7 +759,7 @@
   if (Kind == SymbolKind::S_GPROC32_ID || Kind == SymbolKind::S_LPROC32_ID) {
 SmallVector Refs;
 auto Content = RecordData.drop_front(sizeof(RecordPrefix));
-CVSymbol Sym(Kind, RecordData);
+CVSymbol Sym(RecordData);
 discoverTypeIndicesInSymbol(Sym, Refs);
 assert(Refs.size() == 1);
 assert(Refs.front().Count == 1);
@@ -959,7 +959,7 @@
 MutableArrayRef RecordBytes;
 if (NeedsRealignment) {
   RecordBytes = copyAndAlignSymbol(Sym, AlignedSymbolMem);
-  Sym = CVSymbol(Sym.kind(), RecordBytes);
+  Sym = CVSymbol(RecordBytes);
 } else {
   // Otherwise, we can actually mutate the symbol directly, since we
   // copied it to apply relocations.
@@ -983,7 +983,7 @@
 // An object file may have S_xxx_ID symbols, but these get converted to
 // "real" symbols in a PDB.
 translateIdSymbols(RecordBytes, TMerger.getIDTable());
-Sym = CVSymbol(symbolKind(RecordBytes), RecordBytes);
+Sym = CVSymbol(RecordBytes);
 
 // If this record refers to an offset in the object file's string table,
 // add that item to the global PDB string table and re-write the index.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60201: Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357654: Make clangd-fuzzer use the normal 
add_llvm_fuzzer() machinery (authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60201?vs=193492=193630#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60201/new/

https://reviews.llvm.org/D60201

Files:
  clangd/CMakeLists.txt
  clangd/fuzzer/CMakeLists.txt
  clangd/fuzzer/ClangdFuzzer.cpp
  clangd/fuzzer/DummyClangdMain.cpp
  clangd/fuzzer/clangd-fuzzer.cpp

Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -116,7 +116,8 @@
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()
 add_subdirectory(tool)
Index: clangd/fuzzer/CMakeLists.txt
===
--- clangd/fuzzer/CMakeLists.txt
+++ clangd/fuzzer/CMakeLists.txt
@@ -2,13 +2,10 @@
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )
Index: clangd/fuzzer/clangd-fuzzer.cpp
===
--- clangd/fuzzer/clangd-fuzzer.cpp
+++ clangd/fuzzer/clangd-fuzzer.cpp
@@ -0,0 +1,42 @@
+//===-- ClangdFuzzer.cpp - Fuzz clangd ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a function that runs clangd on a single input.
+/// This function is then linked into the Fuzzer library.
+///
+//===--===//
+
+#include "ClangdLSPServer.h"
+#include "ClangdServer.h"
+#include "CodeComplete.h"
+#include "FSProvider.h"
+#include 
+#include 
+
+using namespace clang::clangd;
+
+extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  if (size == 0)
+return 0;
+
+  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
+  std::FILE *In = fmemopen(data, size, "r");
+  auto Transport = newJSONTransport(In, llvm::nulls(),
+/*InMirror=*/nullptr, /*Pretty=*/false,
+/*Style=*/JSONStreamStyle::Delimited);
+  RealFileSystemProvider FS;
+  CodeCompleteOptions CCOpts;
+  CCOpts.EnableSnippets = false;
+  ClangdServer::Options Opts;
+
+  // Initialize and run ClangdLSPServer.
+  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false, Opts);
+  LSPServer.run();
+  return 0;
+}
Index: clangd/fuzzer/DummyClangdMain.cpp
===
--- clangd/fuzzer/DummyClangdMain.cpp
+++ clangd/fuzzer/DummyClangdMain.cpp
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementation of main so we can build and test without linking libFuzzer.
+//
+//===--===//
+
+#include "llvm/FuzzMutate/FuzzerCLI.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+int main(int argc, char *argv[]) {
+  return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
+}
Index: clangd/fuzzer/ClangdFuzzer.cpp
===
--- clangd/fuzzer/ClangdFuzzer.cpp
+++ clangd/fuzzer/ClangdFuzzer.cpp
@@ -1,42 +0,0 @@
-//===-- ClangdFuzzer.cpp - Fuzz clangd ===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//

[clang-tools-extra] r357654 - Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Apr  3 17:05:53 2019
New Revision: 357654

URL: http://llvm.org/viewvc/llvm-project?rev=357654=rev
Log:
Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

This allows building it even if no fuzzer is enabled. (Sadly, it only
builds on Linux at the moment.)

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

Added:
clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp
clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp
Removed:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=357654=357653=357654=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Apr  3 17:05:53 2019
@@ -116,7 +116,8 @@ add_clang_library(clangDaemon
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()
 add_subdirectory(tool)

Modified: clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt?rev=357654=357653=357654=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt Wed Apr  3 17:05:53 
2019
@@ -2,13 +2,10 @@ include_directories(${CMAKE_CURRENT_SOUR
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks 
unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@ target_link_libraries(clangd-fuzzer
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )

Removed: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=357653=auto
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (removed)
@@ -1,42 +0,0 @@
-//===-- ClangdFuzzer.cpp - Fuzz clangd 
===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-///
-/// \file
-/// \brief This file implements a function that runs clangd on a single input.
-/// This function is then linked into the Fuzzer library.
-///
-//===--===//
-
-#include "ClangdLSPServer.h"
-#include "ClangdServer.h"
-#include "CodeComplete.h"
-#include "FSProvider.h"
-#include 
-#include 
-
-using namespace clang::clangd;
-
-extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
-  if (size == 0)
-return 0;
-
-  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
-  std::FILE *In = fmemopen(data, size, "r");
-  auto Transport = newJSONTransport(In, llvm::nulls(),
-/*InMirror=*/nullptr, /*Pretty=*/false,
-/*Style=*/JSONStreamStyle::Delimited);
-  RealFileSystemProvider FS;
-  CodeCompleteOptions CCOpts;
-  CCOpts.EnableSnippets = false;
-  ClangdServer::Options Opts;
-
-  // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false, Opts);
-  LSPServer.run();
-  return 0;
-}

Added: clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp?rev=357654=auto
==
--- clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp (added)
+++ clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp Wed Apr  3 
17:05:53 2019
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// 

[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Stephen Hines via Phabricator via cfe-commits
srhines marked an inline comment as done.
srhines added inline comments.



Comment at: clang/test/Driver/debug-options.c:280
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"

aprantl wrote:
> What's that for?
Look at Line 30. You added references to it from a while ago, but it didn't 
exist.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60238/new/

https://reviews.llvm.org/D60238



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


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:1691
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);

I don't have an issue with these changes if you want to make them, but they 
should be committed separately.



Comment at: clang/lib/CodeGen/CGCall.cpp:4384-4385
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }

I think we should make CGDebugInfo responsible for calling setMetadata. In some 
sense, "heapallocsite" metadata is debug info, so it makes sense that it would 
be documented there. Also, if there are other places where we need to add this 
metadata, we won't have to duplicate this string literal.

So, CGDebugInfo should have some new method 
`addHeapAllocSiteMetadata(Instruction *CallSite, QualType Ty)`, and that can 
call the private getOrCreateType method. Sound good?



Comment at: clang/test/CodeGen/debug-info-codeview-heapallocsite.c:13
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}

We should expect this test case to grow, so it would be good to add more 
context around here. Something like:
  CHECK-LABEL: define{{.*}} @call_alloc
  CHECK: call i8* @myalloc(i64 1) {{.*}} !heapallocsite ...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60237/new/

https://reviews.llvm.org/D60237



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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/test/Driver/debug-options.c:280
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"

What's that for?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60238/new/

https://reviews.llvm.org/D60238



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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Stephen Hines via Phabricator via cfe-commits
srhines created this revision.
srhines added a reviewer: aprantl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
srhines added subscribers: pirama, chh.

In the future, Android releases will support DWARF 5, but we need to
ensure that older targets only have DWARF 4 generated for them. This
patch inserts that verification for all Android releases now. The patch
also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
missing G_DWARF2 check label).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60238

Files:
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-03 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

Emit !heapallocsite in the metadata for calls to functions marked with
__declspec(allocator). Eventually this will be emitted as S_HEAPALLOCSITE debug
info in codeview.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60237

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];
+  return p;
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,9 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Get debug info for MSAllocator metadata.
+  llvm::MDNode *getMSAllocatorMetadata(QualType Ty, SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,20 @@
   return T;
 }
 
+llvm::MDNode *CGDebugInfo::getMSAllocatorMetadata(QualType D,
+  SourceLocation Loc) {
+  // FIXME: return the type that return value is cast to
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+  return node;
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,17 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4541,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -1688,7 +1688,7 @@
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+

[PATCH] D60235: [CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan

2019-04-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a subscriber: ldionne.
phosek added a comment.

In D60235#1454152 , @mcgrathr wrote:

> IMHO the library code should use `#if !__has_feature(...)` to avoid the 
> definitions entirely when built with a sanitizer whose runtime provides them.
>  But this is a fine way to achieve that while we wait for those libraries to 
> be fixed for sanitized builds.


I agree, D60176  implements that but @ldionne 
thinks that we should go with the CMake option.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60235/new/

https://reviews.llvm.org/D60235



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


r357643 - add periods

2019-04-03 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Wed Apr  3 15:19:07 2019
New Revision: 357643

URL: http://llvm.org/viewvc/llvm-project?rev=357643=rev
Log:
add periods

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

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=357643=357642=357643=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Wed Apr  3 15:19:07 2019
@@ -1688,7 +1688,7 @@ EmitAtomicUpdateValue(CodeGenFunction 
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);
 LValue UpdateLVal;
 if (AtomicLVal.isBitField()) {
@@ -1721,7 +1721,7 @@ EmitAtomicUpdateValue(CodeGenFunction 
 }
 UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation());
   }
-  // Store new value in the corresponding memory area
+  // Store new value in the corresponding memory area.
   RValue NewRVal = UpdateOp(UpRVal);
   if (NewRVal.isScalar()) {
 CGF.EmitStoreThroughLValue(NewRVal, DesiredLVal);
@@ -1786,7 +1786,7 @@ void AtomicInfo::EmitAtomicUpdateOp(
SourceLocation(), 
/*AsValue=*/false);
   EmitAtomicUpdateValue(CGF, *this, OldRVal, UpdateOp, NewAtomicAddr);
   auto *DesiredVal = CGF.Builder.CreateLoad(NewAtomicIntAddr);
-  // Try to write new value using cmpxchg operation
+  // Try to write new value using cmpxchg operation.
   auto Res = EmitAtomicCompareExchangeOp(PHI, DesiredVal, AO, Failure);
   PHI->addIncoming(Res.first, CGF.Builder.GetInsertBlock());
   CGF.Builder.CreateCondBr(Res.second, ExitBB, ContBB);
@@ -1797,7 +1797,7 @@ static void EmitAtomicUpdateValue(CodeGe
   RValue UpdateRVal, Address DesiredAddr) {
   LValue AtomicLVal = Atomics.getAtomicLValue();
   LValue DesiredLVal;
-  // Build new lvalue for temp address
+  // Build new lvalue for temp address.
   if (AtomicLVal.isBitField()) {
 DesiredLVal =
 LValue::MakeBitfield(DesiredAddr, AtomicLVal.getBitFieldInfo(),
@@ -1814,7 +1814,7 @@ static void EmitAtomicUpdateValue(CodeGe
 DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(),
 AtomicLVal.getBaseInfo(), AtomicLVal.getTBAAInfo());
   }
-  // Store new value in the corresponding memory area
+  // Store new value in the corresponding memory area.
   assert(UpdateRVal.isScalar());
   CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal);
 }
@@ -1866,7 +1866,7 @@ void AtomicInfo::EmitAtomicUpdateOp(llvm
   }
   EmitAtomicUpdateValue(CGF, *this, UpdateRVal, NewAtomicAddr);
   auto *DesiredVal = CGF.Builder.CreateLoad(NewAtomicIntAddr);
-  // Try to write new value using cmpxchg operation
+  // Try to write new value using cmpxchg operation.
   auto Res = EmitAtomicCompareExchangeOp(PHI, DesiredVal, AO, Failure);
   PHI->addIncoming(Res.first, CGF.Builder.GetInsertBlock());
   CGF.Builder.CreateCondBr(Res.second, ExitBB, ContBB);


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


[PATCH] D60236: add periods

2019-04-03 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

emit metadata for __declspec(allocator)

add tests for heapallocsite metadata


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60236

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];
+  return p;
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,9 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Get debug info for MSAllocator metadata.
+  llvm::MDNode *getMSAllocatorMetadata(QualType Ty, SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,20 @@
   return T;
 }
 
+llvm::MDNode *CGDebugInfo::getMSAllocatorMetadata(QualType D,
+  SourceLocation Loc) {
+  // FIXME: return the type that return value is cast to
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+  return node;
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,17 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4541,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -1688,7 +1688,7 @@
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);
 LValue UpdateLVal;
 

[PATCH] D60235: [CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan

2019-04-03 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

IMHO the library code should use `#if !__has_feature(...)` to avoid the 
definitions entirely when built with a sanitizer whose runtime provides them.
But this is a fine way to achieve that while we wait for those libraries to be 
fixed for sanitized builds.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60235/new/

https://reviews.llvm.org/D60235



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


[PATCH] D60235: [CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan

2019-04-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, dexonsmith, mehdi_amini, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: clang.

ASan provides its own operator new/delete to intercept all allocations
and deallocations. Currently, they rely on overriding weak symbols that
are already provided by libc++abi and libc++, but that solution is
fragile and breaks in certain scenarios, e.g. when libc++abi is
statically linked into a shared libc++.

Rather we should avoid providing new/delete operators when built with
ASan altogether and rely on new/delete operators provided by the
sanitizer runtime.


Repository:
  rC Clang

https://reviews.llvm.org/D60235

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,6 +142,9 @@
 
set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
 
+
set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF 
CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS 
OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-fuchsia")
   endforeach()


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,6 +142,9 @@
 set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
 
+set(RUNTIMES_${target}-fuchsia-asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}-fuchsia")
   endforeach()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 193604.
hintonda added a comment.
Herald added subscribers: arphaman, mgorny.

- Rename llvm directory to llvm_project.
- Change llvm- to llvm-project-.
- Rename files.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.h
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.h
  clang-tools-extra/clang-tidy/llvm_project/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm_project/HeaderGuardCheck.cpp
  clang-tools-extra/clang-tidy/llvm_project/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/llvm_project/IncludeOrderCheck.cpp
  clang-tools-extra/clang-tidy/llvm_project/IncludeOrderCheck.h
  clang-tools-extra/clang-tidy/llvm_project/LLVMProjectTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm_project/TwineLocalCheck.cpp
  clang-tools-extra/clang-tidy/llvm_project/TwineLocalCheck.h
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  
clang-tools-extra/docs/clang-tidy/checks/google-readability-namespace-comments.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-header-guard.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-include-order.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-project-header-guard.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-project-include-order.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-project-namespace-comment.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-project-twine-local.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/Inputs/Headers/cross-file-c.h
  clang-tools-extra/test/clang-tidy/Inputs/overlapping/o.h
  clang-tools-extra/test/clang-tidy/basic.cpp
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/clang-tidy/export-relpath.cpp
  clang-tools-extra/test/clang-tidy/fix.cpp
  clang-tools-extra/test/clang-tidy/llvm-include-order.cpp
  clang-tools-extra/test/clang-tidy/llvm-project-include-order.cpp
  clang-tools-extra/test/clang-tidy/llvm-project-twine-local.cpp
  clang-tools-extra/test/clang-tidy/llvm-twine-local.cpp
  clang-tools-extra/test/clang-tidy/overlapping.cpp
  clang-tools-extra/test/clang-tidy/select-checks.cpp
  clang-tools-extra/test/clang-tidy/serialize-diagnostics.cpp
  clang-tools-extra/test/clang-tidy/warnings-as-errors-diagnostics.cpp
  clang-tools-extra/test/clang-tidy/warnings-as-errors-plural.cpp
  clang-tools-extra/test/clang-tidy/warnings-as-errors.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
  clang-tools-extra/unittests/clang-tidy/LLVMProjectModuleTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/LLVMProjectModuleTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/LLVMProjectModuleTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/LLVMProjectModuleTest.cpp
@@ -1,10 +1,8 @@
 #include "ClangTidyTest.h"
-#include "llvm/HeaderGuardCheck.h"
-#include "llvm/IncludeOrderCheck.h"
+#include "llvm_project/HeaderGuardCheck.h"
+#include "llvm_project/IncludeOrderCheck.h"
 #include "gtest/gtest.h"
 
-using namespace clang::tidy::llvm;
-
 namespace clang {
 namespace tidy {
 namespace test {
@@ -14,7 +12,7 @@
 static std::string runHeaderGuardCheck(StringRef Code, const Twine ,
Optional ExpectedWarning) {
   std::vector Errors;
-  std::string Result = test::runCheckOnCode(
+  std::string Result = test::runCheckOnCode(
   Code, , Filename, std::string("-xc++-header"));
   if (Errors.size() != (size_t)ExpectedWarning.hasValue())
 return "invalid error count";
@@ -25,7 +23,7 @@
 }
 
 namespace {
-struct WithEndifComment : public LLVMHeaderGuardCheck {
+struct WithEndifComment : public llvm_project::LLVMHeaderGuardCheck {
   WithEndifComment(StringRef Name, ClangTidyContext *Context)
   : LLVMHeaderGuardCheck(Name, Context) {}
   bool shouldSuggestEndifComment(StringRef Filename) override { return true; }
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -11,7 +11,7 @@
   ClangTidyOptionsTest.cpp
   IncludeInserterTest.cpp
   

[PATCH] D60161: Expose non-trivial struct helpers for Swift.

2019-04-03 Thread Tony Allevato via Phabricator via cfe-commits
allevato added inline comments.



Comment at: clang/include/clang/CodeGen/CodeGenABITypes.h:93
+llvm::BasicBlock::iterator InsertPoint, llvm::Value *Dst,
+CharUnits Alignment, QualType QT);
+

rjmccall wrote:
> Hmm.  I think it might be better to just have this return a function pointer; 
> emitting a call in a different frontend's function can be pretty fraught if 
> that frontend wants to handle e.g. unwinding.  The interface should document 
> the ABI of the returned function pointer.  Callers might be able to take 
> advantage of a function pointer in different ways, e.g. by using it directly 
> in Swift's value-witness tables on targets where the calling conventions 
> align.
> 
> In the long run, I'd definitely like to make this interface capable of doing 
> some limited code-generation tasks, e.g. to load or store bit-fields, but I 
> suspect that we'll need to think about that a bit more carefully and that we 
> might want to avoid anything that involves a call.
That makes sense—getting this working was a bit tricky and passing the BB and 
insert point didn't exactly seem like the cleanest approach.

I'll work on the alternate approach you suggested and circle back around when I 
have it working with the corresponding Swift changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60161/new/

https://reviews.llvm.org/D60161



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


[PATCH] D55463: Introduce a source minimizer that reduces source to directives that might affect the dependency list for a compilation

2019-04-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@Bigcheese  Initial tool posted to https://reviews.llvm.org/D60233 .


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55463/new/

https://reviews.llvm.org/D55463



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


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: Bigcheese.
Herald added subscribers: jfb, dexonsmith, jkorous, mgorny.
Herald added a project: clang.

This patch introduces an outline for the `clang-scan-deps` tool that will be 
used to implement fast dependency discovery phase using implicit modules for 
explicit module builds.

The initial version of the tool works by computing non-modular header 
dependencies for files in the compilation database without any optimizations 
(i.e. without source minimization from https://reviews.llvm.org/D55463). The 
tool spawns a number of worker threads to run the clang compiler workers in 
parallel.

The immediate goal for `clang-scan-deps` is to create a `ClangScanDeps` library 
which will be used to build up this tool to use the source minimization and 
caching multi-threaded filesystem to implement the optimized non-incremental 
dependency scanning phase for a non-modular build. This will allow us to do 
benchmarks and comparisons for performance that the minimization and caching 
give us, and maybe setup CI to track that performance. @Bigcheese will then 
extend the tool to have the support for computing modular dependencies for 
Clang modules. The tool could possibly interact with build systems in the 
future if desired, but it's not our immediate goal.

This tool is based on code that was included in the original WIP patch I posted 
before the dev meeting last October: https://reviews.llvm.org/D53354 .


Repository:
  rC Clang

https://reviews.llvm.org/D60233

Files:
  test/ClangScanDeps/Inputs/header.h
  test/ClangScanDeps/Inputs/regular_cdb.json
  test/ClangScanDeps/regular_cdb.cpp
  tools/CMakeLists.txt
  tools/clang-scan-deps/CMakeLists.txt
  tools/clang-scan-deps/ClangScanDeps.cpp

Index: tools/clang-scan-deps/ClangScanDeps.cpp
===
--- /dev/null
+++ tools/clang-scan-deps/ClangScanDeps.cpp
@@ -0,0 +1,211 @@
+//===-- ClangScanDeps.cpp - Implementation of clang-scan-deps -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/FrontendTool/Utils.h"
+#include "clang/Tooling/JSONCompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/Options.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/Threading.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+/// A clang tool that runs the preprocessor only for the given compiler
+/// invocation.
+class PreprocessorOnlyTool : public tooling::ToolAction {
+public:
+  PreprocessorOnlyTool(StringRef WorkingDirectory)
+  : WorkingDirectory(WorkingDirectory) {}
+
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *Files,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+// Create a compiler instance to handle the actual work.
+CompilerInstance Compiler(std::move(PCHContainerOps));
+Compiler.setInvocation(std::move(Invocation));
+Files->getFileSystemOpts().WorkingDir = WorkingDirectory;
+Compiler.setFileManager(Files);
+
+// Create the compiler's actual diagnostics engine.
+Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
+if (!Compiler.hasDiagnostics())
+  return false;
+
+Compiler.createSourceManager(*Files);
+
+auto Action = llvm::make_unique();
+const bool Success = Compiler.ExecuteAction(*Action);
+Files->clearStatCache();
+return Success;
+  }
+
+private:
+  StringRef WorkingDirectory;
+};
+
+/// A proxy file system that doesn't call `chdir` when changing the working
+/// directory of a clang tool.
+class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
+public:
+  ProxyFileSystemWithoutChdir(
+  llvm::IntrusiveRefCntPtr FS)
+  : ProxyFileSystem(std::move(FS)) {}
+
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+assert(!CWD.empty() && "empty CWD");
+return CWD;
+  }
+
+  std::error_code setCurrentWorkingDirectory(const Twine ) override {
+CWD = Path.str();
+return {};
+  }
+
+private:
+  std::string CWD;
+};
+
+/// The high-level implementation of the dependency discovery tool that runs on
+/// an individual worker thread.
+class DependencyScanningTool {
+public:
+  DependencyScanningTool(const tooling::CompilationDatabase )
+  : 

[libunwind] r357640 - [libunwind] Export the unw_* symbols as weak symbols

2019-04-03 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Apr  3 14:50:03 2019
New Revision: 357640

URL: http://llvm.org/viewvc/llvm-project?rev=357640=rev
Log:
[libunwind] Export the unw_* symbols as weak symbols

libunwind defines the _Unwind_* ABI used by libc++abi. This ABI is a
stable quasi-standard common between multiple implementations such as
LLVM and GNU. The _U* symbol name space is also safely within the symbol
name space that standard C & C++ reserve for the implementation.

Futhermore, libunwind also defines several unw_* symbols, and references
these from the _Unwind_* entry points so the standard/reserved part of
the ABI is dependent on the unw_* part of the ABI. This is not OK for a
C or C++ implementation. The unw_* symbols are reserved for C and extern
"C" used by application code.

This change renames each unw_* function to __unw* and adds a weak alias
unw_* to keep the public  ABI unchanged for backwards
compatibility. Every reference to unw_* in the implementation has been
changed to use __unw* so that if other unw_* definitions are in force
because nothing uses  in a particular program, no _Unwind*
code path depends on any unw_* symbol. Furthemore, __unw_* symbols are
hidden, which saves PLT overhead in the shared library case.

In the future, we should cconsider untangling the unw_* API/ABI from the
_Unwind_* API/ABI. The internal API backing the _Unwind_* ABI
implementation should not rely on any nonstandard symbols not in the
implementation-reserved name space. This would then allow separating the
_Unwind_* API/ABI from unw_* entirely, but that's a more substantial
change that's going to require more significant refactoring.

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

Modified:
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/Unwind-EHABI.cpp
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/Unwind-sjlj.c
libunwind/trunk/src/UnwindLevel1-gcc-ext.c
libunwind/trunk/src/UnwindLevel1.c
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/config.h
libunwind/trunk/src/libunwind.cpp
libunwind/trunk/src/libunwind_ext.h

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=357640=357639=357640=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Wed Apr  3 14:50:03 2019
@@ -2154,7 +2154,7 @@ inline Registers_arm::Registers_arm(cons
 _saved_vfp_d16_d31(false) {
   static_assert((check_fit::does_fit),
 "arm registers do not fit into unw_context_t");
-  // See unw_getcontext() note about data.
+  // See __unw_getcontext() note about data.
   memcpy(&_registers, registers, sizeof(_registers));
   memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad));
   memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31));
@@ -2433,7 +2433,7 @@ inline const char *Registers_arm::getReg
 
 inline bool Registers_arm::validFloatRegister(int regNum) const {
   // NOTE: Consider the intel MMX registers floating points so the
-  // unw_get_fpreg can be used to transmit the 64-bit data back.
+  // __unw_get_fpreg can be used to transmit the 64-bit data back.
   return ((regNum >= UNW_ARM_D0) && (regNum <= UNW_ARM_D31))
 #if defined(__ARM_WMMX)
   || ((regNum >= UNW_ARM_WR0) && (regNum <= UNW_ARM_WR15))

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=357640=357639=357640=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Wed Apr  3 14:50:03 2019
@@ -179,7 +179,7 @@ static _Unwind_Reason_Code unwindOneFram
   if (result != _URC_CONTINUE_UNWIND)
 return result;
 
-  if (unw_step(reinterpret_cast(context)) != UNW_STEP_SUCCESS)
+  if (__unw_step(reinterpret_cast(context)) != 
UNW_STEP_SUCCESS)
 return _URC_FAILURE;
   return _URC_CONTINUE_UNWIND;
 }
@@ -440,17 +440,18 @@ unwind_phase1(unw_context_t *uc, unw_cur
   // In this implementation, the phases don't share the VRS backing store.
   // Instead, they are passed the original |uc| and they create a new VRS
   // from scratch thus achieving the same effect.
-  unw_init_local(cursor, uc);
+  __unw_init_local(cursor, uc);
 
   // Walk each frame looking for a place to stop.
   for (bool handlerNotFound = true; handlerNotFound;) {
 
 // See if frame has code to run (has personality routine).
 unw_proc_info_t frameInfo;
-if (unw_get_proc_info(cursor, ) != UNW_ESUCCESS) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
- "failed => _URC_FATAL_PHASE1_ERROR",
- static_cast(exception_object));
+if (__unw_get_proc_info(cursor, ) != 

[PATCH] D60161: Expose non-trivial struct helpers for Swift.

2019-04-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/CodeGen/CodeGenABITypes.h:93
+llvm::BasicBlock::iterator InsertPoint, llvm::Value *Dst,
+CharUnits Alignment, QualType QT);
+

Hmm.  I think it might be better to just have this return a function pointer; 
emitting a call in a different frontend's function can be pretty fraught if 
that frontend wants to handle e.g. unwinding.  The interface should document 
the ABI of the returned function pointer.  Callers might be able to take 
advantage of a function pointer in different ways, e.g. by using it directly in 
Swift's value-witness tables on targets where the calling conventions align.

In the long run, I'd definitely like to make this interface capable of doing 
some limited code-generation tasks, e.g. to load or store bit-fields, but I 
suspect that we'll need to think about that a bit more carefully and that we 
might want to avoid anything that involves a call.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60161/new/

https://reviews.llvm.org/D60161



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


[PATCH] D59852: [IR] Create new method in the Function class (NFC)

2019-04-03 Thread Evandro Menezes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357638: [IR] Create new method in `Function` class (NFC) 
(authored by evandro, committed by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59852?vs=192379=193597#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59852/new/

https://reviews.llvm.org/D59852

Files:
  lib/CodeGen/CGCall.cpp


Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1809,8 +1809,7 @@
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(),
- F.hasFnAttribute(llvm::Attribute::OptimizeNone),
+  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }


Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1809,8 +1809,7 @@
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(),
- F.hasFnAttribute(llvm::Attribute::OptimizeNone),
+  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357638 - [IR] Create new method in `Function` class (NFC)

2019-04-03 Thread Evandro Menezes via cfe-commits
Author: evandro
Date: Wed Apr  3 14:27:03 2019
New Revision: 357638

URL: http://llvm.org/viewvc/llvm-project?rev=357638=rev
Log:
[IR] Create new method in `Function` class (NFC)

Create method `optForNone()` testing for the function level equivalent of
`-O0` and refactor appropriately.

Differential revision: https://reviews.llvm.org/D59852

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

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=357638=357637=357638=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Apr  3 14:27:03 2019
@@ -1809,8 +1809,7 @@ void CodeGenModule::ConstructDefaultFnAt
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(),
- F.hasFnAttribute(llvm::Attribute::OptimizeNone),
+  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }


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


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-03 Thread Hui Huang via Phabricator via cfe-commits
Hui added inline comments.



Comment at: test/CodeGenCXX/debug-info-composite-triviality.cpp:88
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialE",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
-struct NonTrivialE : Trivial, NonTrivial {

probinson wrote:
> This one used to be flagged nontrivial, and now it's not flagged?
The base struct 'Trivial' was removed  and this case became duplicated since it 
is now similar with 'struct NonTrivialD'. Could be very easy to add it back per 
request.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59347/new/

https://reviews.llvm.org/D59347



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193584.
ymandel added a subscriber: ABataev.
ymandel added a comment.

Sever dependency of clangToolingRefactor on clangTooling via FixIt.

Transformer used FixIt, which causes a problematic dependency.  This diff copies
the (minimal) code from FixIt to Transformer.cpp to break the dependency. For
the future, though, we should consider whether the FixIt library should live
somewhere accessible to components in Refactoring (perhaps Core?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -0,0 +1,389 @@
+//===- unittest/Tooling/TransformerTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Transformer.h"
+
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+using ast_matchers::anyOf;
+using ast_matchers::argumentCountIs;
+using ast_matchers::callee;
+using ast_matchers::callExpr;
+using ast_matchers::cxxMemberCallExpr;
+using ast_matchers::cxxMethodDecl;
+using ast_matchers::cxxRecordDecl;
+using ast_matchers::declRefExpr;
+using ast_matchers::expr;
+using ast_matchers::functionDecl;
+using ast_matchers::hasAnyName;
+using ast_matchers::hasArgument;
+using ast_matchers::hasDeclaration;
+using ast_matchers::hasElse;
+using ast_matchers::hasName;
+using ast_matchers::hasType;
+using ast_matchers::ifStmt;
+using ast_matchers::member;
+using ast_matchers::memberExpr;
+using ast_matchers::namedDecl;
+using ast_matchers::on;
+using ast_matchers::pointsTo;
+using ast_matchers::to;
+using ast_matchers::unless;
+
+using llvm::StringRef;
+
+constexpr char KHeaderContents[] = R"cc(
+  struct string {
+string(const char*);
+char* c_str();
+int size();
+  };
+  int strlen(const char*);
+
+  namespace proto {
+  struct PCFProto {
+int foo();
+  };
+  struct ProtoCommandLineFlag : PCFProto {
+PCFProto& GetProto();
+  };
+  }  // namespace proto
+)cc";
+
+static ast_matchers::internal::Matcher
+isOrPointsTo(const clang::ast_matchers::DeclarationMatcher ) {
+  return anyOf(hasDeclaration(TypeMatcher), pointsTo(TypeMatcher));
+}
+
+static std::string format(StringRef Code) {
+  const std::vector Ranges(1, Range(0, Code.size()));
+  auto Style = format::getLLVMStyle();
+  const auto Replacements = format::reformat(Style, Code, Ranges);
+  auto Formatted = applyAllReplacements(Code, Replacements);
+  if (!Formatted) {
+ADD_FAILURE() << "Could not format code: "
+  << llvm::toString(Formatted.takeError());
+return std::string();
+  }
+  return *Formatted;
+}
+
+static void compareSnippets(StringRef Expected,
+ const llvm::Optional ) {
+  ASSERT_TRUE(MaybeActual) << "Rewrite failed. Expecting: " << Expected;
+  auto Actual = *MaybeActual;
+  std::string HL = "#include \"header.h\"\n";
+  auto I = Actual.find(HL);
+  if (I != std::string::npos)
+Actual.erase(I, HL.size());
+  EXPECT_EQ(format(Expected), format(Actual));
+}
+
+// FIXME: consider separating this class into its own file(s).
+class ClangRefactoringTestBase : public testing::Test {
+protected:
+  void appendToHeader(StringRef S) { FileContents[0].second += S; }
+
+  void addFile(StringRef Filename, StringRef Content) {
+FileContents.emplace_back(Filename, Content);
+  }
+
+  llvm::Optional rewrite(StringRef Input) {
+std::string Code = ("#include \"header.h\"\n" + Input).str();
+auto Factory = newFrontendActionFactory();
+if (!runToolOnCodeWithArgs(
+Factory->create(), Code, std::vector(), "input.cc",
+"clang-tool", std::make_shared(),
+FileContents)) {
+  return None;
+}
+auto ChangedCodeOrErr =
+applyAtomicChanges("input.cc", Code, Changes, ApplyChangesSpec());
+if (auto Err = ChangedCodeOrErr.takeError()) {
+  llvm::errs() << "Change failed: " << llvm::toString(std::move(Err))
+   << "\n";
+  return None;
+}
+return *ChangedCodeOrErr;
+  }
+
+  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
+Transformer T(std::move(Rule),
+  [this](const 

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Ilya, this diff fixes the breakage. PTAL.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376



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


[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2019-04-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added inline comments.



Comment at: lib/Driver/ToolChains/AMDGPU.h:25
+/// TODO: Generalize to handle libclc.
+class RocmInstallationDetector {
+private:

yaxunl wrote:
> I don't think we should detect ROCm installation here. We are compiling code 
> for amdgpu not only on ROCm, but also on amdgpu-pro and windows. Many cases, 
> people want to compile code for amdgpu on systems without ROCm installed.
> 
> Compiilng code for amdgpu does not really depend on ROCm. We only depend on 
> device library.
> 
> It makes more sense to have a AMDGPUDeviceLibDetector which works on ROCm, 
> amdgpu-pro, and windows. Also we need an option -amdgpu-device-lib-path to 
> override the default amdgpu device lib path.
Being able to cross compile without a rocm installation is one of my primary 
goals here. I don't know what the install paths look like for those other 
drivers. It would be best if everything could agree on a single default install 
location for these to search, which is mostly a naming problem. In the patch 
as-is, the rocm-path is serving as -amdgpu-device-lib-path, but this is a 
naming question


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59321/new/

https://reviews.llvm.org/D59321



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel reopened this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Reopening to fix the breakage caused by previous attempt at commit.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376



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


r357629 - [OPENMP]Add codegen for reduction vars with allocate clause, NFC.

2019-04-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr  3 12:59:09 2019
New Revision: 357629

URL: http://llvm.org/viewvc/llvm-project?rev=357629=rev
Log:
[OPENMP]Add codegen for reduction vars with allocate clause, NFC.

Added test for the reduction variables with the allocate clause.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=357629=357628=357629=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Wed Apr  3 12:59:09 2019
@@ -10,6 +10,16 @@
 #ifndef HEADER
 #define HEADER
 
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;
+
 volatile double g, g_orig;
 volatile double  = g_orig;
 
@@ -124,7 +134,7 @@ int main() {
   for (int i = 0; i < 10; ++i)
 ;
 #pragma omp parallel
-#pragma omp for reduction(& : var3)
+#pragma omp for reduction(& : var3) allocate(omp_cgroup_mem_alloc: var3)
   for (int i = 0; i < 10; ++i)
 ;
   return tmain();
@@ -778,7 +788,6 @@ int main() {
 // CHECK: define internal void [[MAIN_MICROTASK6]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [4 x [[S_FLOAT_TY]]]* 
dereferenceable(48) %{{.+}})
 
 // CHECK: [[VAR3_ORIG_ADDR:%.+]] = alloca [4 x [[S_FLOAT_TY]]]*,
-// CHECK: [[VAR3_PRIV:%.+]] = alloca [4 x [[S_FLOAT_TY]]],
 
 // Reduction list for runtime.
 // CHECK: [[RED_LIST:%.+]] = alloca [1 x i8*],
@@ -788,12 +797,15 @@ int main() {
 // CHECK: [[VAR3_ORIG:%.+]] = load [4 x [[S_FLOAT_TY]]]*, [4 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
 // CHECK: store [4 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]], [4 x [[S_FLOAT_TY]]]** 
[[VAR3_ORIG_ADDR:%.+]],
 // CHECK: [[VAR3_ORIG:%.+]] = load [4 x [[S_FLOAT_TY]]]*, [4 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
+// CHECK: [[ALLOCATOR:%.+]] = load i8**, i8*** @omp_cgroup_mem_alloc,
+// CHECK: [[VAR3_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID:%.+]], i64 
48, i8** [[ALLOCATOR]])
+// CHECK: [[VAR3_PRIV:%.+]] = bitcast i8* [[VAR3_VOID_PTR]] to [4 x %struct.S]*
 // CHECK: getelementptr inbounds [4 x [[S_FLOAT_TY]]], [4 x [[S_FLOAT_TY]]]* 
[[VAR3_PRIV]], i32 0, i32 0
 // CHECK: bitcast [4 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]] to [[S_FLOAT_TY]]*
 // CHECK: getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* %{{.+}}, i64 4
 
 // CHECK: store [4 x [[S_FLOAT_TY]]]* [[VAR3_PRIV]], [4 x [[S_FLOAT_TY]]]** %
-
+// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[VAR3_VOID_PTR]], i8** 
[[ALLOCATOR]])
 // CHECK: ret void
 
 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT_42]]()


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


[PATCH] D24639: [Sema] Warn when returning a lambda that captures a local variable by reference

2019-04-03 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In D24639#1453795 , @bgianfo wrote:

> Is there a reason why this was never merged?
>  Has the functionality been folded in in some other revision?
>
> I saw a bug recently which would have been caught by exactly this, which 
> would have been awesome.
>  How can we get this merged?


Just never got reviewed, then I must of got distracted with other things and 
stopped pinging. I think it's a useful diagnostic, so would be nice to have. As 
far as landing this, it just needs to be rebased and reviewed. If you (or 
anyone else) is interested in this, feel free to commandeer this revision. 
Otherwise I might come back to it later.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D24639/new/

https://reviews.llvm.org/D24639



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


[PATCH] D59797: [COFF] Reduce the size of Chunk and SectionChunk, NFC

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D59797#1452440 , @MaskRay wrote:

> > this reduces the sum of heap allocations ... These numbers exclude memory 
> > mapped files
>
> May I ask how you counted the memory usage minus memory mapped files?


I'm using the Visual Studio memory profiler tool, which I believe just tracks 
heap allocations. It doesn't look at virtual memory or file mappings at all, it 
just sums the total size of all active heap allocations. So, it's not a 
complete picture of memory usage, but it represents the memory that we have the 
most control over.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59797/new/

https://reviews.llvm.org/D59797



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


[PATCH] D46140: [coroutines] Add std::experimental::task type

2019-04-03 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker marked 3 inline comments as done.
lewissbaker added inline comments.



Comment at: include/experimental/task:160
+__get_allocator<_CharAlloc>(__pointer, __size);
+_CharAlloc __allocatorOnStack = _VSTD::move(__allocatorInFrame);
+__allocatorInFrame.~_CharAlloc();

This should use explicit move construction rather than implicit move 
construction.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46140/new/

https://reviews.llvm.org/D46140



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


[PATCH] D59309: [clang-format] BreakAfterReturnType ignored on functions with numeric template parameters

2019-04-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3177-3178
   return false;
 // Don't split tagged template literal so there is a break between the tag
 // identifier and template string.
 if (Left.is(tok::identifier) && Right.is(TT_TemplateString)) {

klimek wrote:
> I don't understand this yet, which test broke? The TT_TemplateString looks 
> like it's a JS thing?
I'm not sure what you mean here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59309/new/

https://reviews.llvm.org/D59309



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


[PATCH] D60225: [clang-format] [PR19056] Add support for indenting class members and methods one level under the modifiers

2019-04-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, djasper, JonasToth, russellmcc, reuk.
MyDeveloperDay added a project: clang-tools-extra.

Code::Blocks and Qt Creator code uses a style guide which recommends indenting 
the next line after the access modifier e.g.

  class Foo
  {
int abc;
  
public:
int def;
void foo();
  
private:
int ghi;
void foo();
  }

The following patch with the addition of a new option

  AccessModifierIndentation: true

This PR was raised a long time ago (2014), and recently was pinged for an update

The following patch aim to address this issue, potentially allowing 
clang-format to be used (rather than astyle)


https://reviews.llvm.org/D60225

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1982,6 +1982,209 @@
Style));
 }
 
+TEST_F(FormatTest, FormatAccessModifierIndentation) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AccessModifierIndentation = false;
+  EXPECT_EQ("class Foo1 {\n"
+"  int i;\n"
+"\n"
+"public:\n"
+"  int j;\n"
+"  int k;\n"
+"  Foo1() {}\n"
+"\n"
+"private:\n"
+"  Bar() {}\n"
+"  int l;\n"
+"  int m;\n"
+"\n"
+"protected:\n"
+"  Ping() {}\n"
+"  int n;\n"
+"  int o;\n"
+"};\n",
+format("class Foo1 {\n"
+   "int i;\n"
+   "public:\n"
+   "int j;\n"
+   "int k;\n"
+   "Foo1() {}\n"
+   "private:\n"
+   "Bar() {}\n"
+   "int l;\n"
+   "int m;\n"
+   "protected:\n"
+   "Ping() {}\n"
+   "int n;\n"
+   "int o;\n"
+   "};\n",
+   Style));
+
+  Style.AccessModifierIndentation = true;
+  EXPECT_EQ("class Foo2 {\n"
+"int i;\n"
+"\n"
+"public:\n"
+"int j;\n"
+"int k;\n"
+"Foo2() {}\n"
+"\n"
+"private:\n"
+"Bar() {}\n"
+"int l;\n"
+"int m;\n"
+"\n"
+"protected:\n"
+"Ping() {}\n"
+"int n;\n"
+"int o;\n"
+"};\n",
+format("class Foo2 {\n"
+   "int i;\n"
+   "public:\n"
+   "int j;\n"
+   "int k;\n"
+   "Foo2() {}\n"
+   "private:\n"
+   "Bar() {}\n"
+   "int l;\n"
+   "int m;\n"
+   "protected:\n"
+   "Ping() {}\n"
+   "int n;\n"
+   "int o;\n"
+   "};\n",
+   Style));
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  Style.AccessModifierIndentation = false;
+  EXPECT_EQ("class Foo3\n"
+"{\n"
+"  int i;\n"
+"\n"
+"public:\n"
+"  int j;\n"
+"  int k;\n"
+"  Foo3() {}\n"
+"\n"
+"private:\n"
+"  Bar() {}\n"
+"  int l;\n"
+"  int m;\n"
+"\n"
+"protected:\n"
+"  Ping() {}\n"
+"  int n;\n"
+"  int o;\n"
+"};\n",
+format("class Foo3 {\n"
+   "int i;\n"
+   "public:\n"
+   "int j;\n"
+   "int k;\n"
+   "Foo3() {}\n"
+   "private:\n"
+   "Bar() {}\n"
+   "int l;\n"
+   "int m;\n"
+   "protected:\n"
+   "Ping() {}\n"
+   "int n;\n"
+   "int o;\n"
+   "};\n",
+   Style));
+
+  Style.AccessModifierIndentation = true;
+  EXPECT_EQ("class Foo4\n"
+"{\n"
+"int i;\n"
+"\n"
+"public:\n"
+"int j;\n"
+"int k;\n"
+"Foo4() {}\n"
+"\n"
+"private:\n"
+"Bar() {}\n"
+"int l;\n"
+"int m;\n"
+"\n"
+"protected:\n"
+"Ping() {}\n"
+"int n;\n"
+"int 

[PATCH] D60201: Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60201/new/

https://reviews.llvm.org/D60201



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


[PATCH] D24639: [Sema] Warn when returning a lambda that captures a local variable by reference

2019-04-03 Thread Brian Gianforcaro via Phabricator via cfe-commits
bgianfo added a comment.
Herald added subscribers: dexonsmith, jkorous.

Is there a reason why this was never merged?
Has the functionality been folded in in some other revision?

I saw a bug recently where this warning would have been great.
How can we get this merged?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D24639/new/

https://reviews.llvm.org/D24639



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


r357625 - [OPENMP]Add codegen for lastprivate vars with allocate clause, NFC.

2019-04-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr  3 12:12:47 2019
New Revision: 357625

URL: http://llvm.org/viewvc/llvm-project?rev=357625=rev
Log:
[OPENMP]Add codegen for lastprivate vars with allocate clause, NFC.

Added test for the lastprivatized variables with the allocate clause.

Modified:
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp?rev=357625=357624=357625=diff
==
--- cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp Wed Apr  3 12:12:47 2019
@@ -14,6 +14,16 @@
 #ifndef HEADER
 #define HEADER
 
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;
+
 struct SS {
   int a;
   int b : 4;
@@ -456,12 +466,12 @@ int main() {
 A::x++;
   }
 #pragma omp parallel
-#pragma omp for firstprivate(f) lastprivate(f)
+#pragma omp for allocate(omp_const_mem_alloc: f) firstprivate(f) lastprivate(f)
   for (int i = 0; i < 2; ++i) {
 A::x++;
   }
 #pragma omp parallel
-#pragma omp for lastprivate(cnt)
+#pragma omp for allocate(omp_const_mem_alloc :cnt) lastprivate(cnt)
   for (cnt = 0; cnt < 2; ++cnt) {
 A::x++;
   }
@@ -590,15 +600,17 @@ int main() {
 // CHECK: ret void
 
 // CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}})
-// CHECK: [[F_PRIV:%.+]] = alloca float,
 // CHECK-NOT: alloca float
 
 // Check for default initialization.
+// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: [[ALLOCATOR:%.+]] = load i8**, i8*** @omp_const_mem_alloc,
+// CHECK: [[F_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 4, 
i8** [[ALLOCATOR]])
+// CHECK: [[F_PRIV:%.+]] = bitcast i8* [[F_VOID_PTR]] to float*
 // CHECK: [[F_VAL:%.+]] = load float, float* [[F]],
 // CHECK: store float [[F_VAL]], float* [[F_PRIV]],
 
-// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
-// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
 // CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 
[[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* 
%{{.+}}, i32 1, i32 1)
 // 
 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]])
@@ -617,15 +629,16 @@ int main() {
 // CHECK-NEXT: br label %[[LAST_DONE]]
 // CHECK: [[LAST_DONE]]
 
-// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i{{[0-9]+}} [[GTID]])
-// CHECK: ret void
+// CHECK:  call void @__kmpc_free(i32 [[GTID]], i8* [[F_VOID_PTR]], i8** 
[[ALLOCATOR]])
+// CHECK-NEXT: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i{{[0-9]+}} [[GTID]])
+// CHECK-NEXT: ret void
 
 // CHECK: define internal void [[MAIN_MICROTASK3]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}})
-// CHECK: alloca i8,
-// CHECK: [[CNT_PRIV:%.+]] = alloca i8,
 
 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: [[ALLOCATOR:%.+]] = load i8**, i8*** @omp_const_mem_alloc,
+// CHECK: [[CNT_PRIV:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 1, i8** 
[[ALLOCATOR]])
 // CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 
[[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // UB = min(UB, GlobalUB)
 // CHECK-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
@@ -653,8 +666,9 @@ int main() {
 // CHECK-NEXT: br label %[[LAST_DONE]]
 // CHECK: [[LAST_DONE]]
 
-// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i{{[0-9]+}} [[GTID]])
-// CHECK: ret void
+// CHECK:  call void @__kmpc_free(i32 [[GTID]], i8* [[CNT_PRIV]], i8** 
[[ALLOCATOR]])
+// CHECK-NEXT: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i{{[0-9]+}} [[GTID]])
+// CHECK-NEXT: ret void
 
 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],


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


[PATCH] D59321: WIP: AMDGPU: Teach toolchain to link rocm device libs

2019-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Driver/ToolChains/AMDGPU.h:25
+/// TODO: Generalize to handle libclc.
+class RocmInstallationDetector {
+private:

I don't think we should detect ROCm installation here. We are compiling code 
for amdgpu not only on ROCm, but also on amdgpu-pro and windows. Many cases, 
people want to compile code for amdgpu on systems without ROCm installed.

Compiilng code for amdgpu does not really depend on ROCm. We only depend on 
device library.

It makes more sense to have a AMDGPUDeviceLibDetector which works on ROCm, 
amdgpu-pro, and windows. Also we need an option -amdgpu-device-lib-path to 
override the default amdgpu device lib path.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59321/new/

https://reviews.llvm.org/D59321



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


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-04-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_cmath.h:81-90
+__DEVICE__ bool isinf(long double __x) { return ::__isinfl(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 // For inscrutable reasons, __finite(), the double-precision version of
 // __finitef, does not exist when compiling for MacOS.  __isfinited is 
available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isfinite(long double __x) { return ::__finitel(__x); }

CUDA [[ 
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#long-double | 
does not support]]  long double on device side, so I would rather see a 
compilation error when someone attempts to use a long double, as opposed to 
providing inconsistent support for it. 

I wonder if we could just provide declarations for these functions. This should 
allow math_functions.hpp to compile, but would still prevent any use of `long 
double` on device side.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60220/new/

https://reviews.llvm.org/D60220



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


[PATCH] D58121: [analyzer][WIP] Attempt to fix traversing bindings of non-base regions in ClusterAnalysis

2019-04-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Reverted D57230  in rC357620 
.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58121/new/

https://reviews.llvm.org/D58121



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


Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
Thanks.  Any idea why AtomicChange.cpp's inclusion of
clang/Tooling/ReplacementsYaml.h
doesn't cause the same problem?
https://github.com/llvm/llvm-project/blob/master/clang/lib/Tooling/Refactoring/AtomicChange.cpp

On Wed, Apr 3, 2019 at 2:11 PM Alexey Bataev  wrote:

> The problem is that libToolingRefactor is a part of libTooling. And you
> have the dependency from the Tooling/Refactor subdirectory to the outer one
> Tooling/ directory. And it means that libToolingRefactor is a part of
> libTooling, but it must depend on libTooling itself.
>
> -
> Best regards,
> Alexey Bataev
>
> 03.04.2019 14:08, Yitzhak Mandelbaum пишет:
>
> Alexey, thanks for reverting the change. Can you expand on why a
> dependency from libToolingRefactor to libTooling causes a cycle in the dep
> graph? In particular, I can't find the reverse dependency libTooling ->
> libToolingRefactor. If you can expand on that (I presume its a chain rather
> than a direct dependency?) that would be really helpful.
>
> thanks!
>
> On Wed, Apr 3, 2019 at 1:29 PM Yitzhak Mandelbaum 
> wrote:
>
>> I'll revert the change.
>>
>> On Wed, Apr 3, 2019 at 1:00 PM Yitzhak Mandelbaum 
>> wrote:
>>
>>> https://reviews.llvm.org/D60213 for the record
>>>
>>> On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
>>> wrote:
>>>
 Thanks.  Do you have build command I can run before/after to verify my
 fix before I submit?

 On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
 revi...@reviews.llvm.org> wrote:

> ABataev added a comment.
>
> Patch breaks the build with the shared libraries, for example,
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
> Seems to me, you need to add an extra dependency on clangTooling.
> clangToolingCore is not enough.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59376/new/
>
> https://reviews.llvm.org/D59376
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357620 - Revert "[analyzer] Toning down invalidation a bit".

2019-04-03 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Apr  3 11:21:16 2019
New Revision: 357620

URL: http://llvm.org/viewvc/llvm-project?rev=357620=rev
Log:
Revert "[analyzer] Toning down invalidation a bit".

This reverts commit r352473.

The overall idea is great, but it seems to cause unintented consequences
when not only Region Store invalidation but also pointer escape mechanism
was accidentally affected.

Based on discussions in https://reviews.llvm.org/D58121#1452483
and https://reviews.llvm.org/D57230#1434161

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/call-invalidation.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
cfe/trunk/test/Analysis/malloc.c
cfe/trunk/test/Analysis/taint-generic.c
cfe/trunk/test/Analysis/taint-tester.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=357620=357619=357620=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Wed Apr  3 11:21:16 2019
@@ -303,23 +303,11 @@ ProgramStateRef CallEvent::invalidateReg
   for (unsigned Idx = 0, Count = getNumArgs(); Idx != Count; ++Idx) {
 // Mark this region for invalidation.  We batch invalidate regions
 // below for efficiency.
-if (const MemRegion *MR = getArgSVal(Idx).getAsRegion()) {
-  bool UseBaseRegion = true;
-  if (const auto *FR = MR->getAs()) {
-if (const auto *TVR = FR->getSuperRegion()->getAs()) 
{
-  if (!TVR->getValueType()->isUnionType()) {
-ETraits.setTrait(MR, RegionAndSymbolInvalidationTraits::
- TK_DoNotInvalidateSuperRegion);
-UseBaseRegion = false;
-  }
-}
-  }
-  // todo: factor this out + handle the lower level const pointers.
-  if (PreserveArgs.count(Idx))
-ETraits.setTrait(
-UseBaseRegion ? MR->getBaseRegion() : MR,
-RegionAndSymbolInvalidationTraits::TK_PreserveContents);
-}
+if (PreserveArgs.count(Idx))
+  if (const MemRegion *MR = getArgSVal(Idx).getAsRegion())
+ETraits.setTrait(MR->getBaseRegion(),
+
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
+// TODO: Factor this out + handle the lower level const pointers.
 
 ValuesToInvalidate.push_back(getArgSVal(Idx));
 

Modified: cfe/trunk/test/Analysis/call-invalidation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call-invalidation.cpp?rev=357620=357619=357620=diff
==
--- cfe/trunk/test/Analysis/call-invalidation.cpp (original)
+++ cfe/trunk/test/Analysis/call-invalidation.cpp Wed Apr  3 11:21:16 2019
@@ -132,21 +132,18 @@ void testInvalidationThroughBaseRegionPo
   PlainStruct s1;
   s1.x = 1;
   s1.z = 1;
-  s1.y = 1;
   clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
   clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
   // Not only passing a structure pointer through const pointer parameter,
   // but also passing a field pointer through const pointer parameter
   // should preserve the contents of the structure.
   useAnythingConst(&(s1.y));
-  clang_analyzer_eval(s1.y == 1); // expected-warning{{TRUE}}
   clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
   // FIXME: Should say "UNKNOWN", because it is not uncommon to
   // modify a mutable member variable through const pointer.
   clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
   useAnything(&(s1.y));
-  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
-  clang_analyzer_eval(s1.y == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{UNKNOWN}}
 }
 
 

Modified: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp?rev=357620=357619=357620=diff
==
--- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Wed Apr  3 11:21:16 
2019
@@ -358,7 +358,7 @@ template 
 void wontInitialize(const T &);
 
 class PassingToUnknownFunctionTest1 {
-  int a, b; // expected-note{{uninitialized field 'this->b'}}
+  int a, b;
 
 public:
   PassingToUnknownFunctionTest1() {
@@ -368,7 +368,8 @@ public:
   }
 
   PassingToUnknownFunctionTest1(int) {
-mayInitialize(a); // expected-warning{{1 uninitialized field at the end of 
the constructor call}}
+mayInitialize(a);
+// All good!
   }
 
   PassingToUnknownFunctionTest1(int, int) {

Modified: cfe/trunk/test/Analysis/malloc.c
URL: 

Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
Alexey, thanks for reverting the change. Can you expand on why a dependency
from libToolingRefactor to libTooling causes a cycle in the dep graph? In
particular, I can't find the reverse dependency libTooling ->
libToolingRefactor. If you can expand on that (I presume its a chain rather
than a direct dependency?) that would be really helpful.

thanks!

On Wed, Apr 3, 2019 at 1:29 PM Yitzhak Mandelbaum 
wrote:

> I'll revert the change.
>
> On Wed, Apr 3, 2019 at 1:00 PM Yitzhak Mandelbaum 
> wrote:
>
>> https://reviews.llvm.org/D60213 for the record
>>
>> On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
>> wrote:
>>
>>> Thanks.  Do you have build command I can run before/after to verify my
>>> fix before I submit?
>>>
>>> On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
>>> revi...@reviews.llvm.org> wrote:
>>>
 ABataev added a comment.

 Patch breaks the build with the shared libraries, for example,
 http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
 Seems to me, you need to add an extra dependency on clangTooling.
 clangToolingCore is not enough.


 Repository:
   rC Clang

 CHANGES SINCE LAST ACTION
   https://reviews.llvm.org/D59376/new/

 https://reviews.llvm.org/D59376






smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60220: [CUDA][Windows] Final fix for bug 38811 (Step 3 of 3)

2019-04-03 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov created this revision.
emankov added a reviewer: tra.
emankov added a project: clang.
Herald added a subscriber: cfe-commits.

Last fix for the clang Bug 38811  
"Clang fails to compile with CUDA-9.x on Windows".

**[IMPORTANT]**
With that last fix, CUDA has just started being compiling by clang on Windows 
after nearly a year and two clang’s major releases (7 and 8).
As long as the last LLVM release, in which clang was compiling CUDA on Windows 
successfully, was 6.0.1, this fix and two previous have to be included into 
upcoming 7.1.0 and 8.0.1 releases.

[How to repro]

  clang++.exe -x cuda "c:\ProgramData\NVIDIA Corporation\CUDA 
Samples\v9.0\0_Simple\simplePrintf\simplePrintf.cu" -I"c:\ProgramData\NVIDIA 
Corporation\CUDA Samples\v9.0\common\inc" --cuda-gpu-arch=sm_50 
--cuda-path="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0" 
-L"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64" 
-lcudart.lib  -v

[Output]

  In file included from 
C:\GIT\LLVM\trunk-for-submits\llvm-64-release-vs2017-15.9.5\dist\lib\clang\9.0.0\include\__clang_cuda_runtime_wrapper.h:327:
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:390:11: error: no matching 
function for call to '__isinfl'
return (__isinfl(a) != 0);
^~~~
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:2662:14: note: candidate 
function not viable: call to __host__ function from __device__ function
  __func__(int __isinfl(long double a))
   ^
  In file included from :1:
  In file included from 
C:\GIT\LLVM\trunk-for-submits\llvm-64-release-vs2017-15.9.5\dist\lib\clang\9.0.0\include\__clang_cuda_runtime_wrapper.h:327:
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:438:11: error: no matching 
function for call to '__isnanl'
return (__isnanl(a) != 0);
^~~~
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:2672:14: note: candidate 
function not viable: call to __host__ function from __device__ function
  __func__(int __isnanl(long double a))
   ^
  In file included from :1:
  In file included from 
C:\GIT\LLVM\trunk-for-submits\llvm-64-release-vs2017-15.9.5\dist\lib\clang\9.0.0\include\__clang_cuda_runtime_wrapper.h:327:
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:486:11: error: no matching 
function for call to '__finitel'
return (__finitel(a) != 0);
^
  C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v9.0/include\crt/math_functions.hpp:2652:14: note: candidate 
function not viable: call to __host__ function from __device__ function
  __func__(int __finitel(long double a))
   ^
  3 errors generated when compiling for sm_50.

[Solution]
Add missing device functions' declarations and definitions.


Repository:
  rC Clang

https://reviews.llvm.org/D60220

Files:
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h


Index: clang/lib/Headers/__clang_cuda_math_forward_declares.h
===
--- clang/lib/Headers/__clang_cuda_math_forward_declares.h
+++ clang/lib/Headers/__clang_cuda_math_forward_declares.h
@@ -98,12 +98,14 @@
 __DEVICE__ float hypot(float, float);
 __DEVICE__ int ilogb(double);
 __DEVICE__ int ilogb(float);
+__DEVICE__ bool isfinite(long double);
 __DEVICE__ bool isfinite(double);
 __DEVICE__ bool isfinite(float);
 __DEVICE__ bool isgreater(double, double);
 __DEVICE__ bool isgreaterequal(double, double);
 __DEVICE__ bool isgreaterequal(float, float);
 __DEVICE__ bool isgreater(float, float);
+__DEVICE__ bool isinf(long double);
 __DEVICE__ bool isinf(double);
 __DEVICE__ bool isinf(float);
 __DEVICE__ bool isless(double, double);
@@ -112,6 +114,7 @@
 __DEVICE__ bool isless(float, float);
 __DEVICE__ bool islessgreater(double, double);
 __DEVICE__ bool islessgreater(float, float);
+__DEVICE__ bool isnan(long double);
 __DEVICE__ bool isnan(double);
 __DEVICE__ bool isnan(float);
 __DEVICE__ bool isnormal(double);
Index: clang/lib/Headers/__clang_cuda_device_functions.h
===
--- clang/lib/Headers/__clang_cuda_device_functions.h
+++ clang/lib/Headers/__clang_cuda_device_functions.h
@@ -237,6 +237,7 @@
 __DEVICE__ int __ffsll(long long __a) { return __nv_ffsll(__a); }
 __DEVICE__ int __finite(double __a) { return __nv_isfinited(__a); }
 __DEVICE__ int __finitef(float __a) { return __nv_finitef(__a); }
+__DEVICE__ int __finitel(long double __a) { return __finite((double)__a); }
 __DEVICE__ int __float2int_rd(float __a) { return __nv_float2int_rd(__a); }
 __DEVICE__ int __float2int_rn(float __a) { return __nv_float2int_rn(__a); }
 __DEVICE__ int 

r357617 - [OPENMP]Add codegen for firstprivate vars with allocate clause.

2019-04-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr  3 10:57:06 2019
New Revision: 357617

URL: http://llvm.org/viewvc/llvm-project?rev=357617=rev
Log:
[OPENMP]Add codegen for firstprivate vars with allocate clause.

Added codegen/test for the firstprivatized variables with the allocate
clause.

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Apr  3 10:57:06 2019
@@ -1457,7 +1457,13 @@ CodeGenFunction::EmitAutoVarAlloca(const
 
   Address address = Address::invalid();
   Address AllocaAddr = Address::invalid();
-  if (Ty->isConstantSizeType()) {
+  Address OpenMPLocalAddr =
+  getLangOpts().OpenMP
+  ? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
+  : Address::invalid();
+  if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+address = OpenMPLocalAddr;
+  } else if (Ty->isConstantSizeType()) {
 bool NRVO = getLangOpts().ElideConstructors &&
   D.isNRVOVariable();
 
@@ -1500,14 +1506,7 @@ CodeGenFunction::EmitAutoVarAlloca(const
 // unless:
 // - it's an NRVO variable.
 // - we are compiling OpenMP and it's an OpenMP local variable.
-
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  address = OpenMPLocalAddr;
-} else if (NRVO) {
+if (NRVO) {
   // The named return value optimization: allocate this variable in the
   // return slot, so that we can elide the copy when returning this
   // variable (C++0x [class.copy]p34).

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Apr  3 10:57:06 2019
@@ -9768,10 +9768,13 @@ Address CGOpenMPRuntime::getAddressOfLoc
   CharUnits Align = CGM.getContext().getDeclAlign(CVD);
   if (CVD->getType()->isVariablyModifiedType()) {
 Size = CGF.getTypeSize(CVD->getType());
-Align = CGM.getContext().getTypeAlignInChars(CVD->getType());
+// Align the size: ((size + align - 1) / align) * align
+Size = CGF.Builder.CreateNUWAdd(
+Size, CGM.getSize(Align - CharUnits::fromQuantity(1)));
+Size = CGF.Builder.CreateUDiv(Size, CGM.getSize(Align));
+Size = CGF.Builder.CreateNUWMul(Size, CGM.getSize(Align));
   } else {
 CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
-Align = CGM.getContext().getDeclAlign(CVD);
 Size = CGM.getSize(Sz.alignTo(Align));
   }
   llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Apr  3 10:57:06 2019
@@ -750,8 +750,10 @@ bool CodeGenFunction::EmitOMPFirstprivat
   bool ThisFirstprivateIsLastprivate =
   Lastprivates.count(OrigVD->getCanonicalDecl()) > 0;
   const FieldDecl *FD = CapturedStmtInfo->lookup(OrigVD);
+  const auto *VD = cast(cast(IInit)->getDecl());
   if (!MustEmitFirstprivateCopy && !ThisFirstprivateIsLastprivate && FD &&
-  !FD->getType()->isReferenceType()) {
+  !FD->getType()->isReferenceType() &&
+  (!VD || !VD->hasAttr())) {
 EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl());
 ++IRef;
 ++InitsRef;
@@ -760,7 +762,8 @@ bool CodeGenFunction::EmitOMPFirstprivat
   // Do not emit copy for firstprivate constant variables in target 
regions,
   // captured by reference.
   if (DeviceConstTarget && OrigVD->getType().isConstant(getContext()) &&
-  FD && FD->getType()->isReferenceType()) {
+  FD && FD->getType()->isReferenceType() &&
+  (!VD || !VD->hasAttr())) {
 (void)CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(*this,
 OrigVD);
 ++IRef;
@@ -770,7 +773,6 @@ bool CodeGenFunction::EmitOMPFirstprivat
   FirstprivateIsLastprivate =
   FirstprivateIsLastprivate || ThisFirstprivateIsLastprivate;
   if 

[PATCH] D58160: MS ABI: adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-03 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

Closed by commit rG0b28b8b09be7 
: 
Bug-40323: MS ABI adding template static member in the linker directive 
section… (authored by jyu2).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58160/new/

https://reviews.llvm.org/D58160



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

aaron.ballman wrote:
> alexfh wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > hintonda wrote:
> > > > > aaron.ballman wrote:
> > > > > > I do not like that we're removing the namespace qualifier here. I 
> > > > > > would prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 
> > > > > > 5>` if there is a namespace clash.
> > > > > Other than aesthetics, the reason I don't like the idea of fully 
> > > > > scoping these types, at least without a comment, is that the error is 
> > > > > triggered by some other code gets included first, and has nothing to 
> > > > > do with this code -- there's nothing actually wrong with the original 
> > > > > code.  So it could/would be confusing for a reader later on wondering 
> > > > > why you needed to fully scope these types, and not others.
> > > > I would argue that the original code is wrong to not use 
> > > > fully-qualified namespace specifiers. The issue is that we have two 
> > > > different namespaces named `llvm` and have gotten away with poor 
> > > > namespace hygiene by accident. Either we should rename the clang-tidy 
> > > > `llvm` namespace to something that does not conflict, or we should 
> > > > consistently use fully-qualified namespace specifiers when in 
> > > > clang-tidy and needing to refer to an `llvm` namespace explicitly.
> > > > 
> > > > I think this patch goes in the wrong direction by making it easier to 
> > > > limp along with poor namespace hygiene.
> > > By fully qualified, do you mean appending the global namespace, `::` to 
> > > everything?   I actually like using `llvm::`, but `::llvm::` is odd and 
> > > needs explanation.
> > > 
> > > I'd be happy to abandon this change and instead rename the 
> > > `clang::tidy::llvm` to `clang::tidy::something_else`, if that's what the 
> > > community would prefer.
> > > 
> > Aaron, you have  a very good point. We also have a more recent example of a 
> > good namespace hygiene in clang-tidy code: the `abseil` module is not 
> > called `absl` mainly to "avoid collisions with a well-known top-level 
> > namespace" 
> > (https://google.github.io/styleguide/cppguide.html#Namespace_Names).
> > 
> > If we can rename the llvm module to something reasonable ("llvm_project"?) 
> > without breaking the naming invariants (used by the add_new_check.py 
> > script, for example), it would be a much better solution.
> > By fully qualified, do you mean appending the global namespace, :: to 
> > everything? I actually like using llvm::, but ::llvm:: is odd and needs 
> > explanation.
> 
> I mean that within clang-tidy, anywhere we write `llvm::` today, we write 
> `::llvm::` instead when we're talking about the global `llvm` namespace as 
> opposed to the clang-tidy `llvm` namespace.
> 
> > I'd be happy to abandon this change and instead rename the 
> > clang::tidy::llvm to clang::tidy::something_else, if that's what the 
> > community would prefer.
> 
> That's my personal preference. I'm fine with the suggestion from @alexfh of 
> using `llvm_project` instead, but we could also go with `llvm_proj`, 
> `llvm_code`, `llvm_tidy`, etc.
Looks like a consensus.  I'll work up a patch and get back to you.  Thanks 
again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

alexfh wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > hintonda wrote:
> > > > aaron.ballman wrote:
> > > > > I do not like that we're removing the namespace qualifier here. I 
> > > > > would prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` 
> > > > > if there is a namespace clash.
> > > > Other than aesthetics, the reason I don't like the idea of fully 
> > > > scoping these types, at least without a comment, is that the error is 
> > > > triggered by some other code gets included first, and has nothing to do 
> > > > with this code -- there's nothing actually wrong with the original 
> > > > code.  So it could/would be confusing for a reader later on wondering 
> > > > why you needed to fully scope these types, and not others.
> > > I would argue that the original code is wrong to not use fully-qualified 
> > > namespace specifiers. The issue is that we have two different namespaces 
> > > named `llvm` and have gotten away with poor namespace hygiene by 
> > > accident. Either we should rename the clang-tidy `llvm` namespace to 
> > > something that does not conflict, or we should consistently use 
> > > fully-qualified namespace specifiers when in clang-tidy and needing to 
> > > refer to an `llvm` namespace explicitly.
> > > 
> > > I think this patch goes in the wrong direction by making it easier to 
> > > limp along with poor namespace hygiene.
> > By fully qualified, do you mean appending the global namespace, `::` to 
> > everything?   I actually like using `llvm::`, but `::llvm::` is odd and 
> > needs explanation.
> > 
> > I'd be happy to abandon this change and instead rename the 
> > `clang::tidy::llvm` to `clang::tidy::something_else`, if that's what the 
> > community would prefer.
> > 
> Aaron, you have  a very good point. We also have a more recent example of a 
> good namespace hygiene in clang-tidy code: the `abseil` module is not called 
> `absl` mainly to "avoid collisions with a well-known top-level namespace" 
> (https://google.github.io/styleguide/cppguide.html#Namespace_Names).
> 
> If we can rename the llvm module to something reasonable ("llvm_project"?) 
> without breaking the naming invariants (used by the add_new_check.py script, 
> for example), it would be a much better solution.
> By fully qualified, do you mean appending the global namespace, :: to 
> everything? I actually like using llvm::, but ::llvm:: is odd and needs 
> explanation.

I mean that within clang-tidy, anywhere we write `llvm::` today, we write 
`::llvm::` instead when we're talking about the global `llvm` namespace as 
opposed to the clang-tidy `llvm` namespace.

> I'd be happy to abandon this change and instead rename the clang::tidy::llvm 
> to clang::tidy::something_else, if that's what the community would prefer.

That's my personal preference. I'm fine with the suggestion from @alexfh of 
using `llvm_project` instead, but we could also go with `llvm_proj`, 
`llvm_code`, `llvm_tidy`, etc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Reverted in r357612


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60213/new/

https://reviews.llvm.org/D60213



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


Re: [PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
That would be great, thank you.

On Wed, Apr 3, 2019 at 1:28 PM Alexey Bataev via Phabricator <
revi...@reviews.llvm.org> wrote:

> ABataev added a comment.
>
> I can revert it for you, if you want
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D60213/new/
>
> https://reviews.llvm.org/D60213
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357612 - Revert "[LibTooling] Add Transformer, a library for source-to-source transformations."

2019-04-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr  3 10:34:04 2019
New Revision: 357612

URL: http://llvm.org/viewvc/llvm-project?rev=357612=rev
Log:
Revert "[LibTooling] Add Transformer, a library for source-to-source 
transformations."

This reverts commit r357576 to fix the problem with the cyclic
dependencies between libTooling and libToolingRefactor.

Removed:
cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
cfe/trunk/unittests/Tooling/TransformerTest.cpp
Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Removed: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h?rev=357611=auto
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h (removed)
@@ -1,210 +0,0 @@
-//===--- Transformer.h - Clang source-rewriting library -*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-///
-///  \file
-///  Defines a library supporting the concise specification of clang-based
-///  source-to-source transformations.
-///
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_
-#define LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_
-
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/ASTMatchers/ASTMatchersInternal.h"
-#include "clang/Tooling/Refactoring/AtomicChange.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Error.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-namespace clang {
-namespace tooling {
-/// Determines the part of the AST node to replace.  We support this to work
-/// around the fact that the AST does not differentiate various syntactic
-/// elements into their own nodes, so users can specify them relative to a 
node,
-/// instead.
-enum class NodePart {
-  /// The node itself.
-  Node,
-  /// Given a \c MemberExpr, selects the member's token.
-  Member,
-  /// Given a \c NamedDecl or \c CxxCtorInitializer, selects that token of the
-  /// relevant name, not including qualifiers.
-  Name,
-};
-
-using TextGenerator =
-std::function;
-
-/// Description of a source-code transformation.
-//
-// A *rewrite rule* describes a transformation of source code. It has the
-// following components:
-//
-// * Matcher: the pattern term, expressed as clang matchers (with Transformer
-//   extensions).
-//
-// * Target: the source code impacted by the rule. This identifies an AST node,
-//   or part thereof (\c TargetPart), whose source range indicates the extent 
of
-//   the replacement applied by the replacement term.  By default, the extent 
is
-//   the node matched by the pattern term (\c NodePart::Node). Target's are
-//   typed (\c TargetKind), which guides the determination of the node extent
-//   and might, in the future, statically constrain the set of eligible
-//   NodeParts for a given node.
-//
-// * Replacement: a function that produces a replacement string for the target,
-//   based on the match result.
-//
-// * Explanation: explanation of the rewrite.  This will be displayed to the
-//   user, where possible (for example, in clang-tidy fix descriptions).
-//
-// Rules have an additional, implicit, component: the parameters. These are
-// portions of the pattern which are left unspecified, yet named so that we can
-// reference them in the replacement term.  The structure of parameters can be
-// partially or even fully specified, in which case they serve just to identify
-// matched nodes for later reference rather than abstract over portions of the
-// AST.  However, in all cases, we refer to named portions of the pattern as
-// parameters.
-//
-// RewriteRule is constructed in a "fluent" style, by creating a builder and
-// chaining setters of individual components.
-// \code
-//   RewriteRule MyRule = buildRule(functionDecl(...)).replaceWith(...);
-// \endcode
-//
-// The \c Transformer class should then be used to apply the rewrite rule and
-// obtain the corresponding replacements.
-struct RewriteRule {
-  // `Matcher` describes the context of this rule. It should always be bound to
-  // at least `RootId`.  The builder class below takes care of this
-  // binding. Here, we bind it to a trivial Matcher to enable the default
-  // constructor, since DynTypedMatcher has no default constructor.
-  ast_matchers::internal::DynTypedMatcher Matcher = ast_matchers::stmt();
-  // The (bound) id 

Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
I'll revert the change.

On Wed, Apr 3, 2019 at 1:00 PM Yitzhak Mandelbaum 
wrote:

> https://reviews.llvm.org/D60213 for the record
>
> On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
> wrote:
>
>> Thanks.  Do you have build command I can run before/after to verify my
>> fix before I submit?
>>
>> On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> ABataev added a comment.
>>>
>>> Patch breaks the build with the shared libraries, for example,
>>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
>>> Seems to me, you need to add an extra dependency on clangTooling.
>>> clangToolingCore is not enough.
>>>
>>>
>>> Repository:
>>>   rC Clang
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D59376/new/
>>>
>>> https://reviews.llvm.org/D59376
>>>
>>>
>>>
>>>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

hintonda wrote:
> aaron.ballman wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > I do not like that we're removing the namespace qualifier here. I would 
> > > > prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` if there 
> > > > is a namespace clash.
> > > Other than aesthetics, the reason I don't like the idea of fully scoping 
> > > these types, at least without a comment, is that the error is triggered 
> > > by some other code gets included first, and has nothing to do with this 
> > > code -- there's nothing actually wrong with the original code.  So it 
> > > could/would be confusing for a reader later on wondering why you needed 
> > > to fully scope these types, and not others.
> > I would argue that the original code is wrong to not use fully-qualified 
> > namespace specifiers. The issue is that we have two different namespaces 
> > named `llvm` and have gotten away with poor namespace hygiene by accident. 
> > Either we should rename the clang-tidy `llvm` namespace to something that 
> > does not conflict, or we should consistently use fully-qualified namespace 
> > specifiers when in clang-tidy and needing to refer to an `llvm` namespace 
> > explicitly.
> > 
> > I think this patch goes in the wrong direction by making it easier to limp 
> > along with poor namespace hygiene.
> By fully qualified, do you mean appending the global namespace, `::` to 
> everything?   I actually like using `llvm::`, but `::llvm::` is odd and needs 
> explanation.
> 
> I'd be happy to abandon this change and instead rename the 
> `clang::tidy::llvm` to `clang::tidy::something_else`, if that's what the 
> community would prefer.
> 
Aaron, you have  a very good point. We also have a more recent example of a 
good namespace hygiene in clang-tidy code: the `abseil` module is not called 
`absl` mainly to "avoid collisions with a well-known top-level namespace" 
(https://google.github.io/styleguide/cppguide.html#Namespace_Names).

If we can rename the llvm module to something reasonable ("llvm_project"?) 
without breaking the naming invariants (used by the add_new_check.py script, 
for example), it would be a much better solution.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

I can revert it for you, if you want


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60213/new/

https://reviews.llvm.org/D60213



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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D60213#1453516 , @ABataev wrote:

> Nope, it won't work. There is a cyclic dependency, unfortunately. 
> clangTooling depends on clangToolingRefactor already. You need to revert your 
> commit and refactor it to remove the cyclic dependency.


I see. I've never reverted before and I can't seem to find any instructions for 
doing so (only some offhand mentions). If there's a doc on this, can you please 
link me to it?

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60213/new/

https://reviews.llvm.org/D60213



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


r357610 - Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

2019-04-03 Thread Jennifer Yu via cfe-commits
Author: jyu2
Date: Wed Apr  3 10:21:40 2019
New Revision: 357610

URL: http://llvm.org/viewvc/llvm-project?rev=357610=rev
Log:
Bug-40323: MS ABI adding template static member in the linker directive section 
to make sure init function can be called before main.

Added:
cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=357610=357609=357610=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr  3 10:21:40 2019
@@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
+if (getTarget().getCXXABI().isMicrosoft()) {
+  // In The MS C++, MS add template static data member in the linker
+  // drective.
+  assert(COMDATKey);
+  addUsedGlobal(COMDATKey);
+}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the global, so the initializers get folded

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp?rev=357610=auto
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-template-static-init.cpp Wed Apr  3 
10:21:40 2019
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions 
-emit-llvm -o - | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+template  struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template  S ExportedTemplate::s;
+void useExportedTemplate(ExportedTemplate x) {
+  (void)x.s;
+}
+int f();
+namespace selectany_init {
+// MS don't put selectany static var in the linker directive, init routine
+// f() is not getting called if x is not referenced.
+int __declspec(selectany) x = f();
+}
+
+namespace explicit_template_instantiation {
+template  struct A { static  int x; };
+template  int A::x = f();
+template struct A;
+}
+
+namespace implicit_template_instantiation {
+template  struct A { static  int x; };
+template   int A::x = f();
+int g() { return A::x; }
+}
+
+
+template 
+struct X_ {
+  static T ioo;
+  static T init();
+};
+template  T X_::ioo = X_::init();
+template struct X_;
+
+template 
+struct X {
+  static T ioo;
+  static T init();
+};
+// template specialized static data don't need in llvm.used,
+// the static init routine get call from _GLOBAL__sub_I_ routines.
+template <> int X::ioo = X::init();
+template struct X;
+// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", 
i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { 
i32 65535, void ()* 
@"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8* getelementptr inbounds 
(%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) }, { 
i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }]
+// CHECK: @llvm.used = appending global [4 x i8*] [i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.S, %struct.S* 
@"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section 
"llvm.metadata"
+


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


[PATCH] D59932: [clang-tidy] **Prototype**: Add fix description to clang-tidy checks.

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This looks like a more promising direction. Thanks for the readiness to 
experiment with this.

See the comments inline.




Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:130
+
+  // If we have alternative fixes (attached via diagnostic::Notes), we just
+  // choose the first one to apply.

Could you leave a FIXME here to explore options around interactive fix 
selection?



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:132
+  // choose the first one to apply.
+  const llvm::StringMap *ErrorFix = nullptr;
+  if (!Error.Message.Fix.empty())

`ErrorFix` brings more questions than it answers. Maybe `SelectedFix`, 
`ChosenFix`, or just `Fix`?



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:133
+  const llvm::StringMap *ErrorFix = nullptr;
+  if (!Error.Message.Fix.empty())
+ErrorFix = 

nit: I'd add braces here, since the `else` branch has them.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:144
+
+  if (ApplyFixes && ErrorFix) {
+for (const auto  : *ErrorFix) {

The nesting level starts getting out of control here. I'd try to pull the loop 
into a function.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:187
   }
+  reportFix(Diag, Error.Message.Fix);
 }

Why `Error.Message.Fix`? Should this use `*SelectedFix` instead?



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:262
+  for (const auto  : FileAndReplacements.second) {
+if (Repl.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Repl.getFilePath();

nit: Early "continue" would make sense here.

  if (!Repl.isApplicable())
continue;
  ...



Comment at: clang/include/clang/Tooling/Core/Diagnostic.h:46
+
+  /// Fixes for this diagnostic.
+  llvm::StringMap Fix;

Some information from the original comment was lost here:

  /// Fixes to apply, grouped by file path.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59932/new/

https://reviews.llvm.org/D59932



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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Nope, it won't work. There is a cyclic dependency, unfortunately. clangTooling 
depends on clangToolingRefactor already. You need to revert your commit and 
refactor it to remove the cyclic dependency.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60213/new/

https://reviews.llvm.org/D60213



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


Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
https://reviews.llvm.org/D60213 for the record

On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
wrote:

> Thanks.  Do you have build command I can run before/after to verify my fix
> before I submit?
>
> On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> ABataev added a comment.
>>
>> Patch breaks the build with the shared libraries, for example,
>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
>> Seems to me, you need to add an extra dependency on clangTooling.
>> clangToolingCore is not enough.
>>
>>
>> Repository:
>>   rC Clang
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D59376/new/
>>
>> https://reviews.llvm.org/D59376
>>
>>
>>
>>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

You need to provide -DBUILD_SHARED_LIBS=true to cmake. Unfortunately, there is 
a dependency from the libToolingRefactor to libTooling. I don't think it will 
be easy to fix this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376



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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Fixes https://reviews.llvm.org/D59371, which broke the build for shared 
libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60213

Files:
  clang/lib/Tooling/Refactoring/CMakeLists.txt


Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -23,4 +23,5 @@
   clangLex
   clangRewrite
   clangToolingCore
+  clangTooling
   )


Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -23,4 +23,5 @@
   clangLex
   clangRewrite
   clangToolingCore
+  clangTooling
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r357606 - [libunwind] Do not share an object library to create the static/shared libraries

2019-04-03 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Apr  3 09:59:33 2019
New Revision: 357606

URL: http://llvm.org/viewvc/llvm-project?rev=357606=rev
Log:
[libunwind] Do not share an object library to create the static/shared libraries

This change is similar to r356150, with the same motivation.

Modified:
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=357606=357605=357606=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Wed Apr  3 09:59:33 2019
@@ -105,50 +105,16 @@ set_property(SOURCE ${LIBUNWIND_CXX_SOUR
 set_property(SOURCE ${LIBUNWIND_C_SOURCES}
  APPEND_STRING PROPERTY COMPILE_FLAGS " ${LIBUNWIND_C_FLAGS}")
 
-macro(unwind_object_library name)
-  cmake_parse_arguments(ARGS "" "" "DEFINES;FLAGS" ${ARGN})
-
-# Add a object library that contains the compiled source files.
-  add_library(${name} OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
-
-  if(ARGS_DEFINES)
-target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
-  endif()
-
-  set_target_properties(${name}
-PROPERTIES
-  COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
-  POSITION_INDEPENDENT_CODE ON)
-
-  if(ARGS_FLAGS)
-target_compile_options(${name} PRIVATE ${ARGS_FLAGS})
-  endif()
-endmacro()
-
-if(LIBUNWIND_HERMETIC_STATIC_LIBRARY)
-  append_flags_if_supported(UNWIND_STATIC_OBJECTS_FLAGS -fvisibility=hidden)
-  append_flags_if_supported(UNWIND_STATIC_OBJECTS_FLAGS 
-fvisibility-global-new-delete-hidden)
-  unwind_object_library(unwind_static_objects
-DEFINES _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS
-FLAGS ${UNWIND_STATIC_OBJECTS_FLAGS})
-  unwind_object_library(unwind_shared_objects)
-  set(unwind_static_sources $)
-  set(unwind_shared_sources $)
-else()
-  unwind_object_library(unwind_objects)
-  set(unwind_static_sources $)
-  set(unwind_shared_sources $)
-endif()
-
 # Build the shared library.
 if (LIBUNWIND_ENABLE_SHARED)
-  add_library(unwind_shared SHARED ${unwind_shared_sources})
+  add_library(unwind_shared SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
   if(COMMAND llvm_setup_rpath)
 llvm_setup_rpath(unwind_shared)
   endif()
   target_link_libraries(unwind_shared PRIVATE ${libraries})
   set_target_properties(unwind_shared
 PROPERTIES
+  COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
   LINK_FLAGS"${LIBUNWIND_LINK_FLAGS}"
   OUTPUT_NAME   "unwind"
   VERSION   "1.0"
@@ -161,12 +127,21 @@ endif()
 
 # Build the static library.
 if (LIBUNWIND_ENABLE_STATIC)
-  add_library(unwind_static STATIC ${unwind_static_sources})
+  add_library(unwind_static STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
   target_link_libraries(unwind_static PRIVATE ${libraries})
   set_target_properties(unwind_static
 PROPERTIES
+  COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
   LINK_FLAGS"${LIBUNWIND_LINK_FLAGS}"
   OUTPUT_NAME   "unwind")
+
+  if(LIBUNWIND_HERMETIC_STATIC_LIBRARY)
+append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden)
+append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS 
-fvisibility-global-new-delete-hidden)
+target_compile_options(unwind_static PRIVATE 
${UNWIND_STATIC_LIBRARY_FLAGS})
+target_compile_definitions(unwind_static PRIVATE 
_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+  endif()
+
   list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")
   if (LIBUNWIND_INSTALL_STATIC_LIBRARY)
 list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static")


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


Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
Thanks.  Do you have build command I can run before/after to verify my fix
before I submit?

On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
revi...@reviews.llvm.org> wrote:

> ABataev added a comment.
>
> Patch breaks the build with the shared libraries, for example,
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
> Seems to me, you need to add an extra dependency on clangTooling.
> clangToolingCore is not enough.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59376/new/
>
> https://reviews.llvm.org/D59376
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Note that with:

1. https://reviews.llvm.org/D60208 ("[X86] Extend boolean arguments to

inline-asm according to getBooleanType")

2. https://reviews.llvm.org/D58260 ("[INLINER] allow inlining of

blockaddresses if sole uses are callbrs")

3. https://reviews.llvm.org/D56571 ("[RFC prototype] Implementation of

asm-goto support in clang")

I can compile a mainline x86 defconfig Linux kernel and boot it in QEMU.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56571/new/

https://reviews.llvm.org/D56571



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Patch breaks the build with the shared libraries, for example, 
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498. 
Seems to me, you need to add an extra dependency on clangTooling. 
clangToolingCore is not enough.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 193526.
rnk added a comment.

- final updates


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60018/new/

https://reviews.llvm.org/D60018

Files:
  lld/COFF/PDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
  llvm/include/llvm/DebugInfo/CodeView/CVRecord.h
  llvm/include/llvm/DebugInfo/CodeView/RecordSerialization.h
  llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
  llvm/include/llvm/DebugInfo/CodeView/TypeDeserializer.h
  llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
  llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
  llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
  llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp
  llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp
  llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
  llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
  llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
  llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
  llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
  llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
  llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
  llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp

Index: llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
===
--- llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
+++ llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
@@ -42,8 +42,6 @@
 }
 
 inline bool operator==(const CVType , const CVType ) {
-  if (R1.Type != R2.Type)
-return false;
   if (R1.RecordData != R2.RecordData)
 return false;
   return true;
@@ -107,7 +105,7 @@
   GlobalState->Records.push_back(AR);
   GlobalState->Indices.push_back(Builder.writeLeafType(AR));
 
-  CVType Type(TypeLeafKind::LF_ARRAY, Builder.records().back());
+  CVType Type(Builder.records().back());
   GlobalState->TypeVector.push_back(Type);
 
   GlobalState->AllOffsets.push_back(
@@ -369,11 +367,10 @@
   TypeIndex IndexOne = Builder.writeLeafType(Modifier);
 
   // set up a type stream that refers to the above two serialized records.
-  std::vector TypeArray;
-  TypeArray.push_back(
-  CVType(static_cast(Class.Kind), Builder.records()[0]));
-  TypeArray.push_back(
-  CVType(static_cast(Modifier.Kind), Builder.records()[1]));
+  std::vector TypeArray = {
+  {Builder.records()[0]},
+  {Builder.records()[1]},
+  };
   BinaryItemStream ItemStream(llvm::support::little);
   ItemStream.setItems(TypeArray);
   VarStreamArray TypeStream(ItemStream);
Index: llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
===
--- llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
+++ llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
@@ -224,7 +224,7 @@
   // append to the existing line.
   P.formatLine("{0} | {1} [size = {2}",
fmt_align(Index, AlignStyle::Right, Width),
-   formatTypeLeafKind(Record.Type), Record.length());
+   formatTypeLeafKind(Record.kind()), Record.length());
   if (Hashes) {
 std::string H;
 if (Index.toArrayIndex() >= HashValues.size()) {
Index: llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
===
--- llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
+++ llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
@@ -331,7 +331,7 @@
   // append to the existing line.
   P.formatLine("{0} | {1} [size = {2}]",
fmt_align(Offset, AlignStyle::Right, 6),
-   formatSymbolKind(Record.Type), Record.length());
+   formatSymbolKind(Record.kind()), Record.length());
   P.Indent();
   return Error::success();
 }
Index: llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
===
--- llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
+++ llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
@@ -98,7 +98,7 @@
 
   CVType toCodeViewRecord(AppendingTypeTableBuilder ) const override {
 TS.writeLeafType(Record);
-return CVType(Kind, TS.records().back());
+return CVType(TS.records().back());
   }
 
   mutable T Record;
@@ -496,7 +496,7 @@
 Member.Member->writeTo(CRB);
   }
   TS.insertRecord(CRB);
-  return CVType(Kind, TS.records().back());
+  return CVType(TS.records().back());
 }
 
 void MappingTraits::mapping(IO , OneMethodRecord ) {
Index: llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
===
--- llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
+++ llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
@@ -248,7 +248,7 @@
 uint8_t *Buffer = Allocator.Allocate(TotalLen);
 ::memcpy(Buffer, , 

[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked 2 inline comments as done.
rnk added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60018/new/

https://reviews.llvm.org/D60018



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

aaron.ballman wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > I do not like that we're removing the namespace qualifier here. I would 
> > > prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` if there 
> > > is a namespace clash.
> > Other than aesthetics, the reason I don't like the idea of fully scoping 
> > these types, at least without a comment, is that the error is triggered by 
> > some other code gets included first, and has nothing to do with this code 
> > -- there's nothing actually wrong with the original code.  So it 
> > could/would be confusing for a reader later on wondering why you needed to 
> > fully scope these types, and not others.
> I would argue that the original code is wrong to not use fully-qualified 
> namespace specifiers. The issue is that we have two different namespaces 
> named `llvm` and have gotten away with poor namespace hygiene by accident. 
> Either we should rename the clang-tidy `llvm` namespace to something that 
> does not conflict, or we should consistently use fully-qualified namespace 
> specifiers when in clang-tidy and needing to refer to an `llvm` namespace 
> explicitly.
> 
> I think this patch goes in the wrong direction by making it easier to limp 
> along with poor namespace hygiene.
By fully qualified, do you mean appending the global namespace, `::` to 
everything?   I actually like using `llvm::`, but `::llvm::` is odd and needs 
explanation.

I'd be happy to abandon this change and instead rename the `clang::tidy::llvm` 
to `clang::tidy::something_else`, if that's what the community would prefer.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

hintonda wrote:
> aaron.ballman wrote:
> > I do not like that we're removing the namespace qualifier here. I would 
> > prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` if there is 
> > a namespace clash.
> Other than aesthetics, the reason I don't like the idea of fully scoping 
> these types, at least without a comment, is that the error is triggered by 
> some other code gets included first, and has nothing to do with this code -- 
> there's nothing actually wrong with the original code.  So it could/would be 
> confusing for a reader later on wondering why you needed to fully scope these 
> types, and not others.
I would argue that the original code is wrong to not use fully-qualified 
namespace specifiers. The issue is that we have two different namespaces named 
`llvm` and have gotten away with poor namespace hygiene by accident. Either we 
should rename the clang-tidy `llvm` namespace to something that does not 
conflict, or we should consistently use fully-qualified namespace specifiers 
when in clang-tidy and needing to refer to an `llvm` namespace explicitly.

I think this patch goes in the wrong direction by making it easier to limp 
along with poor namespace hygiene.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D59932: [clang-tidy] **Prototype**: Add fix description to clang-tidy checks.

2019-04-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Running out of time today, the patch is not finished yet, but it should be good 
for another initial review/comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59932/new/

https://reviews.llvm.org/D59932



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

aaron.ballman wrote:
> I do not like that we're removing the namespace qualifier here. I would 
> prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` if there is a 
> namespace clash.
Other than aesthetics, the reason I don't like the idea of fully scoping these 
types, at least without a comment, is that the error is triggered by some other 
code gets included first, and has nothing to do with this code -- there's 
nothing actually wrong with the original code.  So it could/would be confusing 
for a reader later on wondering why you needed to fully scope these types, and 
not others.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D59932: [clang-tidy] **Prototype**: Add fix description to clang-tidy checks.

2019-04-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 193510.
hokein added a comment.

Emit the check fix description via diagnostic::note.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59932/new/

https://reviews.llvm.org/D59932

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/test/clang-tidy/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
  clang/include/clang/Tooling/Core/Diagnostic.h
  clang/include/clang/Tooling/DiagnosticsYaml.h
  clang/lib/Tooling/Core/Diagnostic.cpp
  clang/unittests/Tooling/DiagnosticsYamlTest.cpp

Index: clang/unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- clang/unittests/Tooling/DiagnosticsYamlTest.cpp
+++ clang/unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -20,11 +20,13 @@
 using clang::tooling::Diagnostic;
 
 static DiagnosticMessage makeMessage(const std::string , int FileOffset,
- const std::string ) {
+ const std::string ,
+ const StringMap ) {
   DiagnosticMessage DiagMessage;
   DiagMessage.Message = Message;
   DiagMessage.FileOffset = FileOffset;
   DiagMessage.FilePath = FilePath;
+  DiagMessage.Fix = Fix;
   return DiagMessage;
 }
 
@@ -32,10 +34,52 @@
  const std::string , int FileOffset,
  const std::string ,
  const StringMap ) {
-  return Diagnostic(DiagnosticName, makeMessage(Message, FileOffset, FilePath),
-Fix, {}, Diagnostic::Warning, "path/to/build/directory");
+  return Diagnostic(DiagnosticName,
+makeMessage(Message, FileOffset, FilePath, Fix), {},
+Diagnostic::Warning, "path/to/build/directory");
 }
 
+static const char *YAMLContent =
+"---\n"
+"MainSourceFile:  'path/to/source.cpp'\n"
+"Diagnostics: \n"
+"  - DiagnosticName:  'diagnostic#1\'\n"
+"DiagnosticMessage: \n"
+"  Message: 'message #1'\n"
+"  FilePath:'path/to/source.cpp'\n"
+"  FileOffset:  55\n"
+"  Replacements:\n"
+"- FilePath:'path/to/source.cpp'\n"
+"  Offset:  100\n"
+"  Length:  12\n"
+"  ReplacementText: 'replacement #1'\n"
+"  - DiagnosticName:  'diagnostic#2'\n"
+"DiagnosticMessage: \n"
+"  Message: 'message #2'\n"
+"  FilePath:'path/to/header.h'\n"
+"  FileOffset:  60\n"
+"  Replacements:\n"
+"- FilePath:'path/to/header.h'\n"
+"  Offset:  62\n"
+"  Length:  2\n"
+"  ReplacementText: 'replacement #2'\n"
+"  - DiagnosticName:  'diagnostic#3'\n"
+"DiagnosticMessage: \n"
+"  Message: 'message #3'\n"
+"  FilePath:'path/to/source2.cpp'\n"
+"  FileOffset:  72\n"
+"  Replacements:[]\n"
+"Notes:   \n"
+"  - Message: Note1\n"
+"FilePath:'path/to/note1.cpp'\n"
+"FileOffset:  88\n"
+"Replacements:[]\n"
+"  - Message: Note2\n"
+"FilePath:'path/to/note2.cpp'\n"
+"FileOffset:  99\n"
+"Replacements:[]\n"
+"...\n";
+
 TEST(DiagnosticsYamlTest, serializesDiagnostics) {
   TranslationUnitDiagnostics TUD;
   TUD.MainSourceFile = "path/to/source.cpp";
@@ -55,9 +99,9 @@
   TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#3", "message #3", 72,
"path/to/source2.cpp", {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note1", 88, "path/to/note1.cpp"));
+  makeMessage("Note1", 88, "path/to/note1.cpp", {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note2", 99, "path/to/note2.cpp"));
+  makeMessage("Note2", 99, "path/to/note2.cpp", {}));
 
   std::string YamlContent;
   raw_string_ostream YamlContentStream(YamlContent);
@@ -65,80 +109,12 @@
   yaml::Output YAML(YamlContentStream);
   YAML << TUD;
 
-  EXPECT_EQ("---\n"
-"MainSourceFile:  'path/to/source.cpp'\n"
-"Diagnostics: \n"
-"  - DiagnosticName:  'diagnostic#1\'\n"
-"Message: 'message #1'\n"
-"FileOffset:  55\n"
-"FilePath:'path/to/source.cpp'\n"
-"Replacements:\n"
-"  - FilePath:'path/to/source.cpp'\n"
- 

[PATCH] D60203: Updating Chromium's Java import order

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks!

(Test?)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60203/new/

https://reviews.llvm.org/D60203



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


[PATCH] D59985: Re-fix invalid address space generation for clk_event_t arguments of enqueue_kernel builtin function

2019-04-03 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

Alternative way to fix it is to use `isNullPointerConstant` like we do in 
`SemaOpenCLBuiltinEnqueueKernel`. So in case we have a zero literal value we 
can emit `ConstantPointerNull` directly, without `EmitScalarExpr` .


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59985/new/

https://reviews.llvm.org/D59985



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


[PATCH] D60199: [clang-format] Do not emit replacements while regrouping if Cpp includes are OK

2019-04-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357599: [clang-format] Do not emit replacements while 
regrouping if Cpp includes are OK (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60199?vs=193500=193508#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60199/new/

https://reviews.llvm.org/D60199

Files:
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1753,6 +1753,7 @@
 static void sortCppIncludes(const FormatStyle ,
 const SmallVectorImpl ,
 ArrayRef Ranges, StringRef FileName,
+StringRef Code,
 tooling::Replacements , unsigned *Cursor) {
   unsigned IncludesBeginOffset = Includes.front().Offset;
   unsigned IncludesEndOffset =
@@ -1788,6 +1789,10 @@
 
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire block. Otherwise, no replacement is generated.
+  // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is not
+  // enough as additional newlines might be added or removed across #include
+  // blocks. This we handle below by generating the updated #imclude blocks and
+  // comparing it to the original.
   if (Indices.size() == Includes.size() &&
   std::is_sorted(Indices.begin(), Indices.end()) &&
   Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve)
@@ -1808,6 +1813,11 @@
 CurrentCategory = Includes[Index].Category;
   }
 
+  // If the #includes are out of order, we generate a single replacement fixing
+  // the entire range of blocks. Otherwise, no replacement is generated.
+  if (result == Code.substr(IncludesBeginOffset, IncludesBlockSize))
+return;
+
   auto Err = Replaces.add(tooling::Replacement(
   FileName, Includes.front().Offset, IncludesBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
@@ -1876,8 +1886,8 @@
   MainIncludeFound = true;
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
   } else if (!IncludesInBlock.empty() && !EmptyLineSkipped) {
-sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces,
-Cursor);
+sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
+Replaces, Cursor);
 IncludesInBlock.clear();
 FirstIncludeBlock = false;
   }
@@ -1887,8 +1897,10 @@
   break;
 SearchFrom = Pos + 1;
   }
-  if (!IncludesInBlock.empty())
-sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces, Cursor);
+  if (!IncludesInBlock.empty()) {
+sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, Replaces,
+Cursor);
+  }
   return Replaces;
 }
 
Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -8,6 +8,7 @@
 
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+#include "llvm/ADT/None.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -24,9 +25,11 @@
   }
 
   std::string sort(StringRef Code, std::vector Ranges,
-   StringRef FileName = "input.cc") {
+   StringRef FileName = "input.cc",
+   unsigned ExpectedNumRanges = 1) {
 auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+EXPECT_EQ(ExpectedNumRanges, Replaces.size());
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
@@ -35,8 +38,10 @@
 return *Result;
   }
 
-  std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
-return sort(Code, GetCodeRange(Code), FileName);
+  std::string sort(StringRef Code,
+   StringRef FileName = "input.cpp",
+   unsigned ExpectedNumRanges = 1) {
+return sort(Code, GetCodeRange(Code), FileName, ExpectedNumRanges);
   }
 
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
@@ -151,7 +156,7 @@
  "#include \n"
  "#include \n"
  "#include \n"
- "/* clang-format onwards */\n"));
+ "/* clang-format onwards */\n", "input.h", 2));
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
@@ -161,7 +166,8 @@
 "#include \"b.h\"\n",
 sort("#include \"a.h\"\n"
  "#include \"c.h\"\n"
- "#include \"b.h\"\n"));
+ "#include \"b.h\"\n",
+ 

r357599 - [clang-format] Do not emit replacements while regrouping if Cpp includes are OK

2019-04-03 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Apr  3 08:16:04 2019
New Revision: 357599

URL: http://llvm.org/viewvc/llvm-project?rev=357599=rev
Log:
[clang-format] Do not emit replacements while regrouping if Cpp includes are OK

Summary:
Currently clang-format would always emit a replacement for multi-block #include
sections if `IBS_Regroup`, even if the sections are correct:
```
% cat ~/test.h
#include 

#include "b.h"
% bin/clang-format --output-replacements-xml -style=google ~/test.h


#include a.h>#include 
"b.h"

%
```

This change makes clang-format not emit replacements in this case.
The logic is similar to the one implemented for Java in r354452.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=357599=357598=357599=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Apr  3 08:16:04 2019
@@ -1753,6 +1753,7 @@ FindCursorIndex(const SmallVectorImpl ,
 ArrayRef Ranges, StringRef 
FileName,
+StringRef Code,
 tooling::Replacements , unsigned *Cursor) 
{
   unsigned IncludesBeginOffset = Includes.front().Offset;
   unsigned IncludesEndOffset =
@@ -1788,6 +1789,10 @@ static void sortCppIncludes(const Format
 
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire block. Otherwise, no replacement is generated.
+  // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is 
not
+  // enough as additional newlines might be added or removed across #include
+  // blocks. This we handle below by generating the updated #imclude blocks and
+  // comparing it to the original.
   if (Indices.size() == Includes.size() &&
   std::is_sorted(Indices.begin(), Indices.end()) &&
   Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve)
@@ -1808,6 +1813,11 @@ static void sortCppIncludes(const Format
 CurrentCategory = Includes[Index].Category;
   }
 
+  // If the #includes are out of order, we generate a single replacement fixing
+  // the entire range of blocks. Otherwise, no replacement is generated.
+  if (result == Code.substr(IncludesBeginOffset, IncludesBlockSize))
+return;
+
   auto Err = Replaces.add(tooling::Replacement(
   FileName, Includes.front().Offset, IncludesBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
@@ -1876,8 +1886,8 @@ tooling::Replacements sortCppIncludes(co
   MainIncludeFound = true;
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
   } else if (!IncludesInBlock.empty() && !EmptyLineSkipped) {
-sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces,
-Cursor);
+sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
+Replaces, Cursor);
 IncludesInBlock.clear();
 FirstIncludeBlock = false;
   }
@@ -1887,8 +1897,10 @@ tooling::Replacements sortCppIncludes(co
   break;
 SearchFrom = Pos + 1;
   }
-  if (!IncludesInBlock.empty())
-sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces, 
Cursor);
+  if (!IncludesInBlock.empty()) {
+sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, Replaces,
+Cursor);
+  }
   return Replaces;
 }
 

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=357599=357598=357599=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Wed Apr  3 08:16:04 2019
@@ -8,6 +8,7 @@
 
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+#include "llvm/ADT/None.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -24,9 +25,11 @@ protected:
   }
 
   std::string sort(StringRef Code, std::vector Ranges,
-   StringRef FileName = "input.cc") {
+   StringRef FileName = "input.cc",
+   unsigned ExpectedNumRanges = 1) {
 auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+EXPECT_EQ(ExpectedNumRanges, Replaces.size());
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
@@ -35,8 +38,10 @@ protected:
 return *Result;
   }
 
-  std::string sort(StringRef Code, StringRef FileName 

[PATCH] D60203: Updating Chromium's Java import order

2019-04-03 Thread Sam Maier via Phabricator via cfe-commits
SamMaier created this revision.
SamMaier added a reviewer: thakis.
Herald added subscribers: cfe-commits, srhines.
Herald added a project: clang.

Adding in androidx as another import group.


Repository:
  rC Clang

https://reviews.llvm.org/D60203

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -893,9 +893,16 @@
 // See styleguide for import groups:
 // 
https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
-"android",  "com",  "dalvik",
-"junit","org",  "com.google.android.apps.chrome",
-"org.chromium", "java", "javax",
+"android",
+"androidx",
+"com",
+"dalvik",
+"junit",
+"org",
+"com.google.android.apps.chrome",
+"org.chromium",
+"java",
+"javax",
 };
 ChromiumStyle.SortIncludes = true;
   } else if (Language == FormatStyle::LK_JavaScript) {


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -893,9 +893,16 @@
 // See styleguide for import groups:
 // https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
-"android",  "com",  "dalvik",
-"junit","org",  "com.google.android.apps.chrome",
-"org.chromium", "java", "javax",
+"android",
+"androidx",
+"com",
+"dalvik",
+"junit",
+"org",
+"com.google.android.apps.chrome",
+"org.chromium",
+"java",
+"javax",
 };
 ChromiumStyle.SortIncludes = true;
   } else if (Language == FormatStyle::LK_JavaScript) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In D60151#1453099 , @alexfh wrote:

> The change looks fine, but I don't understand the description of this 
> revision. Could you clarify which checkers you're talking about and which bug 
> you observe?


Sorry for not being clearer in my original description.

The error can be triggered by opening up a new `llvm` namespace under 
`clang::tidy` prior to referencing `llvm::SmallSet`, which would happened if a 
new llvm checker that gets included in `LLVMTidyModule.cpp` before 
`HeaderGuardCheck.h` -- `HeaderGuardCheck.h` includes `HeaderFileExternsions.h` 
prior to opening the new `llvm` namespace.  Here's the error message you'd get:

  
llvm-project/clang-tools-extra/clang-tidy/llvm/../utils/../utils/HeaderFileExtensionsUtils.h:24:9:
 error: no template named 'SmallSet' in namespace 'clang::tidy::llvm'; did you 
mean '::llvm::SmallSet'?
  typedef llvm::SmallSet HeaderFileExtensionsSet;
  ^~
  ::llvm::SmallSet
  llvm-project/llvm/include/llvm/ADT/SmallSet.h:134:7: note: '::llvm::SmallSet' 
declared here
  class SmallSet {
^
  
llvm-project/clang-tools-extra/clang-tidy/llvm/../utils/../utils/HeaderFileExtensionsUtils.h:24:30:
 error: no member named 'StringRef' in namespace 'clang::tidy::llvm'
  typedef llvm::SmallSet HeaderFileExtensionsSet;
 ~~^
  2 errors generated.

Here's the one line contrived change needed to demonstrate the error produced 
above, which is the same effect of including an `llvm` checker header before 
including this file:

  --- a/clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
  +++ b/clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
  @@ -16,6 +16,7 @@
  
   namespace clang {
   namespace tidy {
  +namespace llvm {}
   namespace utils {
  
   typedef llvm::SmallSet HeaderFileExtensionsSet;


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60151/new/

https://reviews.llvm.org/D60151



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


[PATCH] D60199: [clang-format] Do not emit replacements while regrouping if Cpp includes are OK

2019-04-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 193500.
krasimir added a comment.

- Address review comments


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60199/new/

https://reviews.llvm.org/D60199

Files:
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -8,6 +8,7 @@
 
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+#include "llvm/ADT/None.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -24,9 +25,11 @@
   }
 
   std::string sort(StringRef Code, std::vector Ranges,
-   StringRef FileName = "input.cc") {
+   StringRef FileName = "input.cc",
+   unsigned ExpectedNumRanges = 1) {
 auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+EXPECT_EQ(ExpectedNumRanges, Replaces.size());
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
@@ -35,8 +38,10 @@
 return *Result;
   }
 
-  std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
-return sort(Code, GetCodeRange(Code), FileName);
+  std::string sort(StringRef Code,
+   StringRef FileName = "input.cpp",
+   unsigned ExpectedNumRanges = 1) {
+return sort(Code, GetCodeRange(Code), FileName, ExpectedNumRanges);
   }
 
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
@@ -151,7 +156,7 @@
  "#include \n"
  "#include \n"
  "#include \n"
- "/* clang-format onwards */\n"));
+ "/* clang-format onwards */\n", "input.h", 2));
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
@@ -161,7 +166,8 @@
 "#include \"b.h\"\n",
 sort("#include \"a.h\"\n"
  "#include \"c.h\"\n"
- "#include \"b.h\"\n"));
+ "#include \"b.h\"\n",
+ "input.h", 0));
 }
 
 TEST_F(SortIncludesTest, MixIncludeAndImport) {
@@ -214,7 +220,7 @@
 sort("#include \"a.h\"\n"
  "#include \"c.h\"\n"
  "\n"
- "#include \"b.h\"\n"));
+ "#include \"b.h\"\n", "input.h", 0));
 }
 
 TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
@@ -458,7 +464,7 @@
 sort("#include \"important_os_header.h\"\n"
  "#include \"c_main.h\"\n"
  "#include \"a_other.h\"\n",
- "c_main.cc"));
+ "c_main.cc", 0));
 }
 
 TEST_F(SortIncludesTest, PriorityGroupsAreSeparatedWhenRegroupping) {
@@ -486,7 +492,7 @@
  "#include \"c_main.h\"\n"
  "\n"
  "#include \"a_other.h\"\n",
- "c_main.cc"));
+ "c_main.cc", 0));
 }
 
 TEST_F(SortIncludesTest, CalculatesCorrectCursorPosition) {
@@ -634,7 +640,17 @@
 sort(""));
+ "-->", "input.h", 0));
+}
+
+TEST_F(SortIncludesTest, DoNotOutputReplacementsForSortedBlocksWithRegrouping) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  std::string Code = R"(
+#include "b.h"
+
+#include 
+)";
+  EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1753,6 +1753,7 @@
 static void sortCppIncludes(const FormatStyle ,
 const SmallVectorImpl ,
 ArrayRef Ranges, StringRef FileName,
+StringRef Code,
 tooling::Replacements , unsigned *Cursor) {
   unsigned IncludesBeginOffset = Includes.front().Offset;
   unsigned IncludesEndOffset =
@@ -1788,6 +1789,10 @@
 
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire block. Otherwise, no replacement is generated.
+  // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is not
+  // enough as additional newlines might be added or removed across #include
+  // blocks. This we handle below by generating the updated #imclude blocks and
+  // comparing it to the original.
   if (Indices.size() == Includes.size() &&
   std::is_sorted(Indices.begin(), Indices.end()) &&
   Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve)
@@ -1808,6 +1813,11 @@
 CurrentCategory = Includes[Index].Category;
   }
 
+  // If the #includes are out of order, we generate a single replacement fixing
+  // the entire range of blocks. Otherwise, no replacement is generated.
+  if (result == Code.substr(IncludesBeginOffset, IncludesBlockSize))
+

[PATCH] D59371: [LibTooling] Add Stencil library for format-string style codegen.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193498.
ymandel added a comment.

Remove noisy default-defined constructors/operators


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59371/new/

https://reviews.llvm.org/D59371

Files:
  clang/include/clang/Tooling/Refactoring/Stencil.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Stencil.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -0,0 +1,204 @@
+//===- unittest/Tooling/StencilTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::Eq;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using tooling::stencil_generators::node;
+using tooling::stencil_generators::snode;
+using tooling::stencil_generators::text;
+
+// In tests, we can't directly match on llvm::Expected since its accessors
+// mutate the object. So, we collapse it to an Optional.
+static llvm::Optional toOptional(llvm::Expected V) {
+  if (V)
+return *V;
+  ADD_FAILURE() << "Losing error in conversion to IsSomething: "
+<< llvm::toString(V.takeError());
+  return llvm::None;
+}
+
+// A very simple matcher for llvm::Optional values.
+MATCHER_P(IsSomething, ValueMatcher, "") {
+  if (!arg)
+return false;
+  return ::testing::ExplainMatchResult(ValueMatcher, *arg, result_listener);
+}
+
+// Create a valid translation-unit from a statement.
+static std::string wrapSnippet(llvm::Twine StatementCode) {
+  return ("auto stencil_test_snippet = []{" + StatementCode + "};").str();
+}
+
+static DeclarationMatcher wrapMatcher(const StatementMatcher ) {
+  return varDecl(hasName("stencil_test_snippet"),
+ hasDescendant(compoundStmt(hasAnySubstatement(Matcher;
+}
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr AstUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+// Matches `Matcher` against the statement `StatementCode` and returns the
+// result. Handles putting the statement inside a function and modifying the
+// matcher correspondingly. `Matcher` should match `StatementCode` exactly --
+// that is, produce exactly one match.
+static llvm::Optional matchStmt(llvm::Twine StatementCode,
+   StatementMatcher Matcher) {
+  auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode));
+  if (AstUnit == nullptr) {
+ADD_FAILURE() << "AST construction failed";
+return llvm::None;
+  }
+  ASTContext  = AstUnit->getASTContext();
+  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  // We expect a single, exact match for the statement.
+  if (Matches.size() != 1) {
+ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
+return llvm::None;
+  }
+  return TestMatch{std::move(AstUnit), MatchResult(Matches[0], )};
+}
+
+class StencilTest : public ::testing::Test {
+protected:
+  // Verifies that the given stencil fails when evaluated on a valid match
+  // result. Binds a statement to "stmt", a (non-member) ctor-initializer to
+  // "init", an expression to "expr" and a (nameless) declaration to "decl".
+  void testError(const Stencil ,
+ ::testing::Matcher Matcher) {
+const std::string Snippet = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  F(1);
+)cc";
+auto StmtMatch = matchStmt(
+Snippet,
+stmt(hasDescendant(
+ cxxConstructExpr(
+ hasDeclaration(decl(hasDescendant(cxxCtorInitializer(
+   isBaseInitializer())
+   .bind("init")))
+.bind("decl")))
+ .bind("expr")))
+.bind("stmt"));
+ASSERT_TRUE(StmtMatch);
+if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+  ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
+} else {
+ 

[PATCH] D59449: [clang-tidy] Integrate clang-tidy-diff.py machinery into run-clang-tidy.py

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D59449#1449664 , @zinovy.nis wrote:

> > Why not just use clang-tidy-diff.py? The clang-tidy-diff.py script has a 
> > distinct and somewhat self-documenting name and a very specific purpose 
> > (find clang-tidy regressions in a patch), while run-clang-tidy.py is more 
> > focused on running over larger bodies of code with a purpose of analyzing 
> > or cleaning up. Is there any benefit in having all functionality in 
> > run-clang-tidy.py?
>
> Both scripts have almost the same implementation, almost the same syntax (at 
> least after -j and -timeout we introduced). So why not merge them.


There are multiple (mostly user-facing) reasons to prefer separate scripts. 
Simplicity, focus, and internal consistency come to mind first. The 
clang-tidy-diff being separate and serving a single purpose makes it easier to 
find, understand, and use. If we merge the two scripts together, will it be 
easy to understand the different use-cases? Will all options be compatible? 
(E.g. -header-filter doesn't make much sense for the --diff mode, since the 
diff defines a different filter)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59449/new/

https://reviews.llvm.org/D59449



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


[PATCH] D59371: [LibTooling] Add Stencil library for format-string style codegen.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193496.
ymandel added a comment.

Sever dependency on NodeId and some general cleanup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59371/new/

https://reviews.llvm.org/D59371

Files:
  clang/include/clang/Tooling/Refactoring/Stencil.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Stencil.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -0,0 +1,204 @@
+//===- unittest/Tooling/StencilTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::Eq;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using tooling::stencil_generators::node;
+using tooling::stencil_generators::snode;
+using tooling::stencil_generators::text;
+
+// In tests, we can't directly match on llvm::Expected since its accessors
+// mutate the object. So, we collapse it to an Optional.
+static llvm::Optional toOptional(llvm::Expected V) {
+  if (V)
+return *V;
+  ADD_FAILURE() << "Losing error in conversion to IsSomething: "
+<< llvm::toString(V.takeError());
+  return llvm::None;
+}
+
+// A very simple matcher for llvm::Optional values.
+MATCHER_P(IsSomething, ValueMatcher, "") {
+  if (!arg)
+return false;
+  return ::testing::ExplainMatchResult(ValueMatcher, *arg, result_listener);
+}
+
+// Create a valid translation-unit from a statement.
+static std::string wrapSnippet(llvm::Twine StatementCode) {
+  return ("auto stencil_test_snippet = []{" + StatementCode + "};").str();
+}
+
+static DeclarationMatcher wrapMatcher(const StatementMatcher ) {
+  return varDecl(hasName("stencil_test_snippet"),
+ hasDescendant(compoundStmt(hasAnySubstatement(Matcher;
+}
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr AstUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+// Matches `Matcher` against the statement `StatementCode` and returns the
+// result. Handles putting the statement inside a function and modifying the
+// matcher correspondingly. `Matcher` should match `StatementCode` exactly --
+// that is, produce exactly one match.
+static llvm::Optional matchStmt(llvm::Twine StatementCode,
+   StatementMatcher Matcher) {
+  auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode));
+  if (AstUnit == nullptr) {
+ADD_FAILURE() << "AST construction failed";
+return llvm::None;
+  }
+  ASTContext  = AstUnit->getASTContext();
+  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  // We expect a single, exact match for the statement.
+  if (Matches.size() != 1) {
+ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
+return llvm::None;
+  }
+  return TestMatch{std::move(AstUnit), MatchResult(Matches[0], )};
+}
+
+class StencilTest : public ::testing::Test {
+protected:
+  // Verifies that the given stencil fails when evaluated on a valid match
+  // result. Binds a statement to "stmt", a (non-member) ctor-initializer to
+  // "init", an expression to "expr" and a (nameless) declaration to "decl".
+  void testError(const Stencil ,
+ ::testing::Matcher Matcher) {
+const std::string Snippet = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  F(1);
+)cc";
+auto StmtMatch = matchStmt(
+Snippet,
+stmt(hasDescendant(
+ cxxConstructExpr(
+ hasDeclaration(decl(hasDescendant(cxxCtorInitializer(
+   isBaseInitializer())
+   .bind("init")))
+.bind("decl")))
+ .bind("expr")))
+.bind("stmt"));
+ASSERT_TRUE(StmtMatch);
+if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+  ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
+} else {

[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Got here trying to understand how D60126  
works.

It seems there's two fairly independent changes here:

- the one described, allow actions to run without a preamble
- defer the blocking getCompileCommand() call until we're building the preamble

Certainly they interact to make zero-latency code completion work, but is it 
possible to pull the latter out of this patch?
There are other approaches to the second part (e.g. giving TUScheduler a 
reference to the global CDB) that might be cleaner. I don't think it needs to 
block D60126 .




Comment at: clangd/TUScheduler.h:204
+   Callback Action,
+   bool AllowFallback = false);
 

I think this isn't orthogonal to `PreambleConsistency`.
When would we use AllowFallback = true but PreambleConsistency = Consistent?

Two possible options:
 - adding a new `StaleOrAbsent` option to PreambleConsistency
 - changing `Stale` to these new semantics, as codeComplete is the only caller
The problem with the latter is we can't put it behind a flag.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59811/new/

https://reviews.llvm.org/D59811



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


[PATCH] D60199: [clang-format] Do not emit replacements while regrouping if Cpp includes are OK

2019-04-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: unittests/Format/SortIncludesTest.cpp:28
   std::string sort(StringRef Code, std::vector Ranges,
+   llvm::Optional ExpectedNumRanges = llvm::None,
StringRef FileName = "input.cc") {

As most cases would pass `1`, maybe it would make sense to make this a class 
member that defaults to `1`? It can be explicitly set in specific tests when 
needed.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60199/new/

https://reviews.llvm.org/D60199



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


r357589 - Whitespace and formatting changes; NFC.

2019-04-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr  3 07:40:00 2019
New Revision: 357589

URL: http://llvm.org/viewvc/llvm-project?rev=357589=rev
Log:
Whitespace and formatting changes; NFC.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=357589=357588=357589=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Apr  3 07:40:00 2019
@@ -921,8 +921,6 @@ and Objective-C methods.
   }];
 }
 
-
-
 def NoDebugDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
@@ -1080,7 +1078,10 @@ can only be placed before an @protocol o
 def ObjCRuntimeVisibleDocs : Documentation {
 let Category = DocCatDecl;
 let Content = [{
-This attribute specifies that the Objective-C class to which it applies is 
visible to the Objective-C runtime but not to the linker. Classes annotated 
with this attribute cannot be subclassed and cannot have categories defined for 
them.
+This attribute specifies that the Objective-C class to which it applies is
+visible to the Objective-C runtime but not to the linker. Classes annotated
+with this attribute cannot be subclassed and cannot have categories defined for
+them.
 }];
 }
 
@@ -2774,8 +2775,6 @@ def PipelineHintDocs : Documentation {
   }];
 }
 
-
-
 def OpenCLUnrollHintDocs : Documentation {
   let Category = DocCatStmt;
   let Content = [{
@@ -3345,7 +3344,7 @@ jumps from i386 arch code).
   }];
 }
 
-def AnyX86NoCfCheckDocs : Documentation{
+def AnyX86NoCfCheckDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
 Jump Oriented Programming attacks rely on tampering with addresses used by


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


[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1116
+def ObjCClassStubDocs : Documentation {
+let Category = DocCatFunction;
+let Content = [{

aaron.ballman wrote:
> slavapestov wrote:
> > aaron.ballman wrote:
> > > This seems like the wrong category -- the attribute doesn't apply to 
> > > functions.
> > Would DocCatType make more sense? Would you like me to change 
> > ObjCRuntimeVisible and a handful of other miscategorized attributes too?
> Oye, it looks like we have a lot of inconsistent categories currently. It's 
> not really a type attribute, it's a declaration attribute, but we don't have 
> such a notion yet. Go ahead and leave this as `DocCatType` for now; I'll see 
> about cleaning this up in a follow-up.
I added `DocCatDecl` in r357585, which I think would be the correct category to 
use here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59628/new/

https://reviews.llvm.org/D59628



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


r357585 - Add a new attribute documentation category for declarations.

2019-04-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr  3 07:26:32 2019
New Revision: 357585

URL: http://llvm.org/viewvc/llvm-project?rev=357585=rev
Log:
Add a new attribute documentation category for declarations.

This moves documentation for some attributes into new categories that are 
hopefully a bit more clear. In general, "Type" documentation should be for 
attributes that appertain to types while "Declaration" documentation should be 
for attributes that appertain to declarations other than functions or variables.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=357585=357584=357585=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Apr  3 07:26:32 2019
@@ -16,6 +16,8 @@ def DocCatFunction : DocumentationCatego
 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
 def DocCatType : DocumentationCategory<"Type Attributes">;
 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
+def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
+
 // Attributes listed under the Undocumented category do not generate any public
 // documentation. Ideally, this category should be used for internal-only
 // attributes which contain no spellings.

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=357585=357584=357585=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Apr  3 07:26:32 2019
@@ -1057,7 +1057,7 @@ implementation of an override in a subcl
 }
 
 def ObjCRuntimeNameDocs : Documentation {
-let Category = DocCatFunction;
+let Category = DocCatDecl;
 let Content = [{
 By default, the Objective-C interface or protocol identifier is used
 in the metadata name for that object. The `objc_runtime_name`
@@ -1078,14 +1078,14 @@ can only be placed before an @protocol o
 }
 
 def ObjCRuntimeVisibleDocs : Documentation {
-let Category = DocCatFunction;
+let Category = DocCatDecl;
 let Content = [{
 This attribute specifies that the Objective-C class to which it applies is 
visible to the Objective-C runtime but not to the linker. Classes annotated 
with this attribute cannot be subclassed and cannot have categories defined for 
them.
 }];
 }
 
 def ObjCBoxableDocs : Documentation {
-let Category = DocCatFunction;
+let Category = DocCatDecl;
 let Content = [{
 Structs and unions marked with the ``objc_boxable`` attribute can be used
 with the Objective-C boxed expression syntax, ``@(...)``.
@@ -1305,7 +1305,7 @@ Also see the documentation for `@availab
 }
 
 def ExternalSourceSymbolDocs : Documentation {
-  let Category = DocCatFunction;
+  let Category = DocCatDecl;
   let Content = [{
 The ``external_source_symbol`` attribute specifies that a declaration 
originates
 from an external source and describes the nature of that source.
@@ -2449,7 +2449,7 @@ behavior of the program is undefined.
 }
 
 def FlagEnumDocs : Documentation {
-  let Category = DocCatType;
+  let Category = DocCatDecl;
   let Content = [{
 This attribute can be added to an enumerator to signal to the compiler that it
 is intended to be used as a flag type. This will cause the compiler to assume
@@ -2459,7 +2459,7 @@ manipulating bits of the enumerator when
 }
 
 def EnumExtensibilityDocs : Documentation {
-  let Category = DocCatType;
+  let Category = DocCatDecl;
   let Content = [{
 Attribute ``enum_extensibility`` is used to distinguish between enum 
definitions
 that are extensible and those that are not. The attribute can take either
@@ -2508,7 +2508,7 @@ standard and instructs clang to be more
 }
 
 def EmptyBasesDocs : Documentation {
-  let Category = DocCatType;
+  let Category = DocCatDecl;
   let Content = [{
 The empty_bases attribute permits the compiler to utilize the
 empty-base-optimization more frequently.
@@ -2518,7 +2518,7 @@ It is only supported when using the Micr
 }
 
 def LayoutVersionDocs : Documentation {
-  let Category = DocCatType;
+  let Category = DocCatDecl;
   let Content = [{
 The layout_version attribute requests that the compiler utilize the class
 layout rules of a particular compiler version.
@@ -2544,7 +2544,7 @@ changes.
 }
 
 def TrivialABIDocs : Documentation {
-  let Category = DocCatVariable;
+  let Category = DocCatDecl;
   let Content = [{
 The ``trivial_abi`` attribute can be applied to a C++ class, struct, or union.
 It instructs the compiler to pass and return the type using the C ABI for the
@@ -2586,7 +2586,7 @@ Attribute ``trivial_abi`` has no effect
 }
 
 def MSInheritanceDocs : Documentation {
-  let 

[PATCH] D60201: Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: bkramer.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov, mgorny.

This allows building it even if no fuzzer is enabled. (Sadly, it only builds on 
Linux at the moment.)


https://reviews.llvm.org/D60201

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/fuzzer/CMakeLists.txt
  clang-tools-extra/clangd/fuzzer/ClangdFuzzer.cpp
  clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp
  clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp


Index: clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementation of main so we can build and test without linking libFuzzer.
+//
+//===--===//
+
+#include "llvm/FuzzMutate/FuzzerCLI.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+int main(int argc, char *argv[]) {
+  return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
+}
Index: clang-tools-extra/clangd/fuzzer/CMakeLists.txt
===
--- clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -2,13 +2,10 @@
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks 
unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -116,7 +116,8 @@
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()
 add_subdirectory(tool)


Index: clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementation of main so we can build and test without linking libFuzzer.
+//
+//===--===//
+
+#include "llvm/FuzzMutate/FuzzerCLI.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+int main(int argc, char *argv[]) {
+  return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
+}
Index: clang-tools-extra/clangd/fuzzer/CMakeLists.txt
===
--- clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -2,13 +2,10 @@
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -116,7 +116,8 @@
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   

[PATCH] D60141: [HIP-Clang] Fat binary should not be produced for non GPU code

2019-04-03 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

Thank you, I submitted a clang-formatted fix for the if statement.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60141/new/

https://reviews.llvm.org/D60141



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


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:8
+
+`extern` is redundant in function declarations
+

koldaniel wrote:
> alexfh wrote:
> > xazax.hun wrote:
> > > alexfh wrote:
> > > > Could you explain, why you think `extern` is redundant in function 
> > > > declarations?
> > > Just to be clear here, do you think there is a case where extern is not 
> > > redundant or you just want the documentation to be extended? 
> > Sorry for being unclear. I would expect a more in-depth explanation of why 
> > the keyword is redundant with references to the appropriate sections of the 
> > standard or some other authoritative source.
> https://en.cppreference.com/w/cpp/language/language_linkage
> 
> The default language linkage is C++, so without any additional parameters it 
> is redundant (**extern "C++"** can also be redundant, but it depends on the 
> context). In C context (**extern "C"**) the situation is the same, **extern** 
> keyword is redundant for function declarations 
> (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf - 6.2.2.5) 
This sort of a description would be helpful in the documentation of the check. 
Users are not likely to search for clarifications in code review comments on 
LLVM Phabricator ;)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D33841/new/

https://reviews.llvm.org/D33841



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


[PATCH] D60139: [clang-tidy] Add misc-placement-new-target-size check

2019-04-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/misc-placement-new-target-size.rst:5
+==
+
+

Eugene.Zelenko wrote:
> Unnecessary empty line.
Somehow empty line is still there.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60139/new/

https://reviews.llvm.org/D60139



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


  1   2   >