[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked 3 inline comments as done.
sepavloff added a comment.

Thank you!




Comment at: lib/Sema/SemaDecl.cpp:11995-12006
+for (auto I : FD->redecls()) {
+  if (I != FD && !I->isInvalidDecl() &&
+  I->getFriendObjectKind() != Decl::FOK_None) {
+if (FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
+  if (Original->isThisDeclarationADefinition()) {
+Definition = I;
+break;

rsmith wrote:
> We should include a comment here explaining why we need to do this (that is, 
> why this doesn't just fall out from the normal `isDefined` check). You can 
> just quote C++ [temp.inst]p2:
> 
> > For the purpose of determining whether an instantiated redeclaration is 
> > valid according to [basic.def.odr] and [class.mem], a declaration that 
> > corresponds to a definition in the template is considered to be a 
> > definition.
Thank you for the reference.


Repository:
  rL LLVM

https://reviews.llvm.org/D30170



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


[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326419: Function definition may have uninstantiated body 
(authored by sepavloff, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D30170?vs=115534=136466#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30170

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/SemaCXX/friend2.cpp

Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -1925,11 +1925,25 @@
 
   SourceRange getSourceRange() const override LLVM_READONLY;
 
-  /// \brief Returns true if the function has a body (definition). The
-  /// function body might be in any of the (re-)declarations of this
-  /// function. The variant that accepts a FunctionDecl pointer will
-  /// set that function declaration to the actual declaration
-  /// containing the body (if there is one).
+  // Function definitions.
+  //
+  // A function declaration may be:
+  // - a non defining declaration,
+  // - a definition. A function may be defined because:
+  //   - it has a body, or will have it in the case of late parsing.
+  //   - it has an uninstantiated body. The body does not exist because the
+  // function is not used yet, but the declaration is considered a
+  // definition and does not allow other definition of this function.
+  //   - it does not have a user specified body, but it does not allow
+  // redefinition, because it is deleted/defaulted or is defined through
+  // some other mechanism (alias, ifunc).
+
+  /// Returns true if the function has a body.
+  ///
+  /// The function body might be in any of the (re-)declarations of this
+  /// function. The variant that accepts a FunctionDecl pointer will set that
+  /// function declaration to the actual declaration containing the body (if
+  /// there is one).
   bool hasBody(const FunctionDecl *) const;
 
   bool hasBody() const override {
@@ -1941,9 +1955,11 @@
   /// specific codegen.
   bool hasTrivialBody() const;
 
-  /// Returns true if the function is defined at all, including a deleted
-  /// definition. Except for the behavior when the function is deleted, behaves
-  /// like hasBody.
+  /// Returns true if the function has a definition that does not need to be
+  /// instantiated.
+  ///
+  /// The variant that accepts a FunctionDecl pointer will set that function
+  /// declaration to the declaration that is a definition (if there is one).
   bool isDefined(const FunctionDecl *) const;
 
   virtual bool isDefined() const {
@@ -1985,8 +2001,7 @@
IsLateTemplateParsed || WillHaveBody || hasDefiningAttr();
   }
 
-  /// Returns whether this specific declaration of the function has a body -
-  /// that is, if it is a non-deleted definition.
+  /// Returns whether this specific declaration of the function has a body.
   bool doesThisDeclarationHaveABody() const {
 return Body || IsLateTemplateParsed;
   }
Index: cfe/trunk/test/SemaCXX/friend2.cpp
===
--- cfe/trunk/test/SemaCXX/friend2.cpp
+++ cfe/trunk/test/SemaCXX/friend2.cpp
@@ -101,6 +101,34 @@
   friend void func_12(int x = 0);  // expected-error{{friend declaration specifying a default argument must be the only declaration}}
 };
 
+// Friend function with uninstantiated body is still a definition.
+
+template struct C20 {
+  friend void func_20() {} // expected-note{{previous definition is here}}
+};
+C20 c20i;
+void func_20() {} // expected-error{{redefinition of 'func_20'}}
+
+template struct C21a {
+  friend void func_21() {} // expected-note{{previous definition is here}}
+};
+template struct C21b {
+  friend void func_21() {} // expected-error{{redefinition of 'func_21'}}
+};
+C21a c21ai;
+C21b c21bi; // expected-note{{in instantiation of template class 'C21b' requested here}}
+
+template struct C22a {
+  friend void func_22() {} // expected-note{{previous definition is here}}
+};
+template struct C22b {
+  friend void func_22();
+};
+C22a c22ai;
+C22b c22bi;
+void func_22() {} // expected-error{{redefinition of 'func_22'}}
+
+
 
 namespace pr22307 {
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12283,9 +12283,36 @@
const FunctionDecl *EffectiveDefinition,
SkipBodyInfo *SkipBody) {
   const FunctionDecl *Definition = EffectiveDefinition;
+  if (!Definition && !FD->isDefined(Definition) && !FD->isCXXClassMember()) {
+// If this is a friend function defined in a class template, it does not
+// have a body until it is used, nevertheless it is 

r326419 - Function definition may have uninstantiated body

2018-02-28 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Feb 28 23:04:11 2018
New Revision: 326419

URL: http://llvm.org/viewvc/llvm-project?rev=326419=rev
Log:
Function definition may have uninstantiated body

Current implementation of `FunctionDecl::isDefined` does not take into
account redeclarations that do not have bodies, but the bodies can be
instantiated from corresponding templated definition. This behavior does
not allow to detect function redefinition in the cases where friend
functions is defined in class templates. For instance, the code:
```
template struct X { friend void f() {} };
X xi;
void f() {}
```
compiles successfully but must fail due to redefinition of `f`. The
declaration of the friend `f` is created when the containing template
`X` is instantiated, but it does not have a body as per 14.5.4p4
because `f` is not odr-used.

With this change the function `Sema::CheckForFunctionRedefinition`
considers functions with uninstantiated bodies as definitions.

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

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/friend2.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=326419=326418=326419=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Feb 28 23:04:11 2018
@@ -1925,11 +1925,25 @@ public:
 
   SourceRange getSourceRange() const override LLVM_READONLY;
 
-  /// \brief Returns true if the function has a body (definition). The
-  /// function body might be in any of the (re-)declarations of this
-  /// function. The variant that accepts a FunctionDecl pointer will
-  /// set that function declaration to the actual declaration
-  /// containing the body (if there is one).
+  // Function definitions.
+  //
+  // A function declaration may be:
+  // - a non defining declaration,
+  // - a definition. A function may be defined because:
+  //   - it has a body, or will have it in the case of late parsing.
+  //   - it has an uninstantiated body. The body does not exist because the
+  // function is not used yet, but the declaration is considered a
+  // definition and does not allow other definition of this function.
+  //   - it does not have a user specified body, but it does not allow
+  // redefinition, because it is deleted/defaulted or is defined through
+  // some other mechanism (alias, ifunc).
+
+  /// Returns true if the function has a body.
+  ///
+  /// The function body might be in any of the (re-)declarations of this
+  /// function. The variant that accepts a FunctionDecl pointer will set that
+  /// function declaration to the actual declaration containing the body (if
+  /// there is one).
   bool hasBody(const FunctionDecl *) const;
 
   bool hasBody() const override {
@@ -1941,9 +1955,11 @@ public:
   /// specific codegen.
   bool hasTrivialBody() const;
 
-  /// Returns true if the function is defined at all, including a deleted
-  /// definition. Except for the behavior when the function is deleted, behaves
-  /// like hasBody.
+  /// Returns true if the function has a definition that does not need to be
+  /// instantiated.
+  ///
+  /// The variant that accepts a FunctionDecl pointer will set that function
+  /// declaration to the declaration that is a definition (if there is one).
   bool isDefined(const FunctionDecl *) const;
 
   virtual bool isDefined() const {
@@ -1985,8 +2001,7 @@ public:
IsLateTemplateParsed || WillHaveBody || hasDefiningAttr();
   }
 
-  /// Returns whether this specific declaration of the function has a body -
-  /// that is, if it is a non-deleted definition.
+  /// Returns whether this specific declaration of the function has a body.
   bool doesThisDeclarationHaveABody() const {
 return Body || IsLateTemplateParsed;
   }

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=326419=326418=326419=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 28 23:04:11 2018
@@ -12283,9 +12283,36 @@ Sema::CheckForFunctionRedefinition(Funct
const FunctionDecl *EffectiveDefinition,
SkipBodyInfo *SkipBody) {
   const FunctionDecl *Definition = EffectiveDefinition;
+  if (!Definition && !FD->isDefined(Definition) && !FD->isCXXClassMember()) {
+// If this is a friend function defined in a class template, it does not
+// have a body until it is used, nevertheless it is a definition, see
+// [temp.inst]p2:
+//
+// ... for the purpose of determining whether an instantiated redeclaration
+// is valid 

[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That's a fair point.  I agree that separate allocas would make this a lot 
cleaner, in both IR and frontend implementation.  We could also set an inalloca 
bit (+ field index? or maybe keep the arg index -> field index mapping on the 
CGFunctionInfo) on each arg info *in addition* to the standard ABI info; then 
most of the cases could just do a final store after their normal 
transformations.  Are there really no cases where you have to e.g. sign-extend 
before doing inalloca, or do you just special-case all that in actual argument 
emission?

Yeah, the block-soup basis of LLVM IR is really annoying for a lot of things 
that otherwise ought to be simple tasks.  I spent some time trying to think 
about how I could support (scoped) dynamic allocas in coroutines for Swift and 
eventually just gave up and introduced a bunch of intrinsics based around a 
token.  Trying to optimize static allocas based on lifetime intrinsics isn't 
going to be a picnic, either.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Driver/Options.td:1419
+def fno_disable_tail_calls_escaping_blocks : Flag<["-"], 
"fno-disable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
+def fdisable_tail_calls_escaping_blocks : Flag<["-"], 
"fdisable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;

rjmccall wrote:
> These are pretty unidiomatic option names.  I would suggest one of these:
>   - [fixed]-fescaping-block-tail-calls[/fixed] (the default) and 
> [fixed]-fno-escaping-block-tail-calls[/fixed]
>   - [fixed]-enable-escaping-block-tail-calls[/fixed] (the default) and 
> [fixed]-disable-escaping-block-tail-calls[/fixed]
Wow, this is not even close to Phabricator markup, I don't know what I was 
thinking.


https://reviews.llvm.org/D43841



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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

TCO is a pretty neglible optimization; its primary advantage is slightly better 
locality for stack memory.

I guess the more compelling argument is that non-escaping blocks can by 
definition only be executed with the original block-creating code still active, 
so someone debugging a crash downstack of a TCO'ed block will still have a 
pretty strong piece of context to start from.  An escaping block, meanwhile, 
could be executed by anything, so TCO'ing it might leave the stack trace with 
absolutely no hint about what's happened.

Alright, I can accept that.




Comment at: include/clang/Driver/Options.td:1419
+def fno_disable_tail_calls_escaping_blocks : Flag<["-"], 
"fno-disable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
+def fdisable_tail_calls_escaping_blocks : Flag<["-"], 
"fdisable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;

These are pretty unidiomatic option names.  I would suggest one of these:
  - [fixed]-fescaping-block-tail-calls[/fixed] (the default) and 
[fixed]-fno-escaping-block-tail-calls[/fixed]
  - [fixed]-enable-escaping-block-tail-calls[/fixed] (the default) and 
[fixed]-disable-escaping-block-tail-calls[/fixed]



Comment at: include/clang/Frontend/CodeGenOptions.def:66
+CODEGENOPT(DisableTailCallsEscapingBlocks, 1, 0) ///< Do not emit tail calls 
for
+ ///< escaping blocks.
 CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what

"from" instead of "for" would be clearer, I think.



Comment at: lib/CodeGen/CodeGenModule.h:469
 
+  llvm::SmallPtrSet NoEscapeBlocks;
+

This seems like something that Sema should store on the BlockDecl.


https://reviews.llvm.org/D43841



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


r326416 - Remove redundant casts. NFC

2018-02-28 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Feb 28 21:43:23 2018
New Revision: 326416

URL: http://llvm.org/viewvc/llvm-project?rev=326416=rev
Log:
Remove redundant casts. NFC

So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.

Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast(baz)) that I didn't touch, since overloading
is a thing and the cast did actually change the type -- just up the
class hierarchy).

I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/TemplateBase.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGCoroutine.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=326416=326415=326416=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Feb 28 21:43:23 2018
@@ -2062,8 +2062,7 @@ public:
   bool isVolatile() const { return 
getType()->castAs()->isVolatile(); }
 
   bool isVirtual() const {
-CXXMethodDecl *CD =
-  
cast(const_cast(this)->getCanonicalDecl());
+CXXMethodDecl *CD = const_cast(this)->getCanonicalDecl();
 
 // Member function is virtual if it is marked explicitly so, or if it is
 // declared in __interface -- then it is automatically pure virtual.

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=326416=326415=326416=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Feb 28 21:43:23 2018
@@ -2169,19 +2169,19 @@ public:
   void setRHS(Expr *E) { SubExprs[RHS] = E; }
 
   Expr *getBase() {
-return cast(getRHS()->getType()->isIntegerType() ? 
getLHS():getRHS());
+return getRHS()->getType()->isIntegerType() ? getLHS() : getRHS();
   }
 
   const Expr *getBase() const {
-return cast(getRHS()->getType()->isIntegerType() ? 
getLHS():getRHS());
+return getRHS()->getType()->isIntegerType() ? getLHS() : getRHS();
   }
 
   Expr *getIdx() {
-return cast(getRHS()->getType()->isIntegerType() ? 
getRHS():getLHS());
+return getRHS()->getType()->isIntegerType() ? getRHS() : getLHS();
   }
 
   const Expr *getIdx() const {
-return cast(getRHS()->getType()->isIntegerType() ? 
getRHS():getLHS());
+return 

[PATCH] D43927: [Coroutines] Schedule coro-split before asan

2018-02-28 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

I wasn't sure what the best way to test this would be. The assertion occurs in 
LLVM, but Clang is responsible for scheduling the passes. If anyone has any 
suggestions, I'd greatly appreciate them!


Repository:
  rC Clang

https://reviews.llvm.org/D43927



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


[PATCH] D43927: [Coroutines] Schedule coro-split before asan

2018-02-28 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: GorNishanov, lewissbaker, EricWF.

The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that
"The second argument, if not null, designates a particular alloca instruction
to be a coroutine promise."

However, if the address sanitizer pass is run before the `@llvm.coro.id`
intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its
second argument is converted, as per the
https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to
an `inttoptr` instruction that accesses the address of the promise.

On optimization levels `-O1` and above, the `-asan` pass is run after
`-coro-early`, `-coro-split`, and `-coro-elide`, and before
`-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan`
is run in between `-coro-early` and `-coro-split`, which causes an
assertion to be hit when the `inttoptr` instruction is forcibly cast to
an `alloca`.

Rearrange the passes such that the coroutine passes are registered
before the sanitizer passes.

Test Plan:
Compile a simple C++ program that uses coroutines in `-O0` with
`-fsanitize-address`, and confirm no assertion is hit:
`clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address 
-fno-omit-frame-pointer`.


Repository:
  rC Clang

https://reviews.llvm.org/D43927

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -539,6 +539,9 @@
addObjCARCOptPass);
   }
 
+  if (LangOpts.CoroutinesTS)
+addCoroutinePassesToExtensionPoints(PMBuilder);
+
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
addBoundsCheckingPass);
@@ -597,9 +600,6 @@
addDataFlowSanitizerPass);
   }
 
-  if (LangOpts.CoroutinesTS)
-addCoroutinePassesToExtensionPoints(PMBuilder);
-
   if (LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addEfficiencySanitizerPass);


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -539,6 +539,9 @@
addObjCARCOptPass);
   }
 
+  if (LangOpts.CoroutinesTS)
+addCoroutinePassesToExtensionPoints(PMBuilder);
+
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
addBoundsCheckingPass);
@@ -597,9 +600,6 @@
addDataFlowSanitizerPass);
   }
 
-  if (LangOpts.CoroutinesTS)
-addCoroutinePassesToExtensionPoints(PMBuilder);
-
   if (LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addEfficiencySanitizerPass);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43696: Reduce hash collisions for reference and pointer types

2018-02-28 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added inline comments.



Comment at: lib/AST/ODRHash.cpp:581
+  void VisitType(const Type *T) {
+ID.AddInteger(T->getTypeClass());
+  }

v.g.vassilev wrote:
> rtrieu wrote:
> > rsmith wrote:
> > > This looks redundant, the above `Visit(const Type*)` function seems to 
> > > already do this.
> > That's correct, VisitType is intended to be empty.  The TypeClass enum 
> > value is added in Visit so that it is the first value added to the data 
> > stream.
> Ok, then I am a little confused. If `VisitType` is supposed to be nop why we 
> call it in all VisitXXX functions.
Each Type calls its parent Type, all the way up to Type.  It's just a manual 
traversal of the Type hierarchy.  Right now, there's nothing in VisitType, but 
there might be in the future.


Repository:
  rC Clang

https://reviews.llvm.org/D43696



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


[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-02-28 Thread Ruslan Nikolaev via Phabricator via cfe-commits
nruslan added a comment.

@aemerson : I am not 100% sure, but I think you are talking about different 
flag. This commit is for supporting a flag to disable stack probes (identical 
flag can be found in MinGW), it basically only applies to PE/COFF (Windows) 
targets. It can be useful to compile UEFI code. By default, Windows will use 
check probes of 4K in x86. A related stack-probe-size allows to vary the size 
of stack probes. This one completely disables them.

By default, stack probes are enabled (i.e., -mstack-arg-probe is the default 
behavior) and have the size of 4K in x86.


Repository:
  rC Clang

https://reviews.llvm.org/D43108



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


[PATCH] D26350: Keep invalid Switch in the AST

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:823
+  CondExpr->isValueDependent() ||
+  isa(CondExpr);
+  unsigned CondWidth =

rsmith wrote:
> It's fragile to assume that the only way you can see an `OpaqueValueExpr` 
> here is by it being created in `ActOnStartOfSwitchStmt`. We could tunnel this 
> information through in another way, though, such as by tracking a bool in the 
> `SwitchStack` in addition to the statement.
> 
> However, perhaps it's time to bite the bullet and add actual support for 
> error nodes in the AST. For example, we could add a new kind of placeholder 
> type for an erroneous expression, and build syntactic expression trees with 
> that type when we encounter errors.
FWIW, I would find error nodes in the AST to be extremely useful.


https://reviews.llvm.org/D26350



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


r326408 - [analyzer] [tests] Create a directory for the log file

2018-02-28 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Feb 28 18:18:54 2018
New Revision: 326408

URL: http://llvm.org/viewvc/llvm-project?rev=326408=rev
Log:
[analyzer] [tests] Create a directory for the log file

Modified:
cfe/trunk/utils/analyzer/SATestUpdateDiffs.py

Modified: cfe/trunk/utils/analyzer/SATestUpdateDiffs.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestUpdateDiffs.py?rev=326408=326407=326408=diff
==
--- cfe/trunk/utils/analyzer/SATestUpdateDiffs.py (original)
+++ cfe/trunk/utils/analyzer/SATestUpdateDiffs.py Wed Feb 28 18:18:54 2018
@@ -35,6 +35,8 @@ def updateReferenceResults(ProjName, Pro
 sys.exit(1)
 
 BuildLogPath = SATestBuild.getBuildLogPath(RefResultsPath)
+Dirname = os.path.dirname(os.path.abspath(BuildLogPath))
+runCmd("mkdir -p '%s'" % Dirname)
 with open(BuildLogPath, "wb+") as PBuildLogFile:
 # Remove reference results: in git, and then again for a good measure
 # with rm, as git might not remove things fully if there are empty


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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Sorry, busy days>< Done.


Repository:
  rL LLVM

https://reviews.llvm.org/D42645



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326405: [analyzer] Add a checker for mmap()s which are both 
writable and executable. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42645?vs=135258=136449#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42645

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  cfe/trunk/test/Analysis/mmap-writeexec.c

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -49,6 +49,7 @@
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
+  MmapWriteExecChecker.cpp
   MisusedMovedObjectChecker.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -0,0 +1,87 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  static int ProtRead;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap", 6) {}
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  int ProtExecOv;
+  int ProtReadOv;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+int MmapWriteExecChecker::ProtRead  = 0x01;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent ,
+ CheckerContext ) const {
+  if (Call.isCalled(MmapFn)) {
+SVal ProtVal = Call.getArgSVal(2); 
+Optional ProtLoc = ProtVal.getAs();
+int64_t Prot = ProtLoc->getValue().getSExtValue();
+if (ProtExecOv != ProtExec)
+  ProtExec = ProtExecOv;
+if (ProtReadOv != ProtRead)
+  ProtRead = ProtReadOv;
+
+// Wrong settings
+if (ProtRead == ProtExec)
+  return;
+
+if ((Prot & (ProtWrite | ProtExec)) == (ProtWrite | ProtExec)) {
+  if (!BT)
+BT.reset(new BugType(this, "W^X check fails, Write Exec prot flags set", "Security"));
+
+  ExplodedNode *N = C.generateNonFatalErrorNode();
+  if (!N)
+return;
+
+  auto Report = llvm::make_unique(
+  *BT, "Both PROT_WRITE and PROT_EXEC flags are set. This can "
+   "lead to exploitable memory regions, which could be overwritten "
+   "with malicious code", N);
+  Report->addRange(Call.getArgSourceRange(2));
+  C.emitReport(std::move(Report));
+}
+  }
+}
+
+void ento::registerMmapWriteExecChecker(CheckerManager ) {
+  MmapWriteExecChecker *Mwec =
+  mgr.registerChecker();
+  Mwec->ProtExecOv =
+mgr.getAnalyzerOptions().getOptionAsInteger("MmapProtExec", 0x04, Mwec);
+  Mwec->ProtReadOv =
+mgr.getAnalyzerOptions().getOptionAsInteger("MmapProtRead", 0x01, Mwec);
+}
Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -414,6 +414,13 @@
   HelpText<"Check for overflows in the arguments to malloc()">,
   DescFile<"MallocOverflowSecurityChecker.cpp">;
 
+// Operating systems specific PROT_READ/PROT_WRITE values is not implemented,
+// the defaults are correct for several common operating systems though, 
+// but may need to be overridden via the related 

r326405 - [analyzer] Add a checker for mmap()s which are both writable and executable.

2018-02-28 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 28 17:27:46 2018
New Revision: 326405

URL: http://llvm.org/viewvc/llvm-project?rev=326405=rev
Log:
[analyzer] Add a checker for mmap()s which are both writable and executable.

This is a security check that warns when both PROT_WRITE and PROT_EXEC are
set during mmap(). If mmap()ed memory is both writable and executable, it makes
it easier for the attacker to execute arbitrary code when contents of this
memory are compromised. Some applications require such mmap()s though, such as
different sorts of JIT.

Re-applied after a revert in r324167.

Temporarily stays in the alpha package because it needs a better way of
determining macro values that are not immediately available in the AST.

Patch by David Carlier!

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
cfe/trunk/test/Analysis/mmap-writeexec.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=326405=326404=326405=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Wed Feb 28 
17:27:46 2018
@@ -414,6 +414,13 @@ def MallocOverflowSecurityChecker : Chec
   HelpText<"Check for overflows in the arguments to malloc()">,
   DescFile<"MallocOverflowSecurityChecker.cpp">;
 
+// Operating systems specific PROT_READ/PROT_WRITE values is not implemented,
+// the defaults are correct for several common operating systems though, 
+// but may need to be overridden via the related analyzer-config flags.
+def MmapWriteExecChecker : Checker<"MmapWriteExec">,
+  HelpText<"Warn on mmap() calls that are both writable and executable">,
+  DescFile<"MmapWriteExecChecker.cpp">;
+
 } // end "alpha.security"
 
 
//===--===//

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=326405=326404=326405=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Wed Feb 28 17:27:46 
2018
@@ -49,6 +49,7 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
+  MmapWriteExecChecker.cpp
   MisusedMovedObjectChecker.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp?rev=326405=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp Wed Feb 28 
17:27:46 2018
@@ -0,0 +1,87 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  static int ProtRead;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap", 6) {}
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  int ProtExecOv;
+  int ProtReadOv;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+int MmapWriteExecChecker::ProtRead  = 0x01;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent ,
+ 

[PATCH] D43840: [CFG] [analyzer] Fix a crash on finding construction context for implicit constructor conversion.

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326402: [CFG] [analyzer] Recall that we only skip NoOp casts 
in construction contexts. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43840?vs=136434=136441#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43840

Files:
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/test/Analysis/cfg-rich-constructors.cpp


Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class 
implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class 
implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {


Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43840: [CFG] [analyzer] Fix a crash on finding construction context for implicit constructor conversion.

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326402: [CFG] [analyzer] Recall that we only skip NoOp casts 
in construction contexts. (authored by dergachev, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D43840

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-rich-constructors.cpp


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class 
implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class 
implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r326402 - [CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.

2018-02-28 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 28 17:09:24 2018
New Revision: 326402

URL: http://llvm.org/viewvc/llvm-project?rev=326402=rev
Log:
[CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.

For now. We should also add support for ConstructorConversion casts as presented
in the attached test case, but this requires more changes because AST around
them seems different.

The check was originally present but was accidentally lost during r326021.

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

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=326402=326401=326402=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Feb 28 17:09:24 2018
@@ -1200,7 +1200,9 @@ void CFGBuilder::findConstructionContext
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {

Modified: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-rich-constructors.cpp?rev=326402=326401=326402=diff
==
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp Wed Feb 28 17:09:24 2018
@@ -484,4 +484,35 @@ void referenceWithFunctionalCast() {
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class 
implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class 
implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion


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


[PATCH] D43840: [CFG] [analyzer] Fix a crash on finding construction context for implicit constructor conversion.

2018-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 136434.
NoQ added a comment.

Add the comment.


https://reviews.llvm.org/D43840

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-rich-constructors.cpp


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class 
implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class 
implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class 
implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -484,4 +484,35 @@
 void constructorInTernaryCondition() {
   const D  = D(1) ? D(2) : D(3);
 }
+
 } // end namespace temporary_object_expr_with_dtors
+
+namespace implicit_constructor_conversion {
+
+class A {};
+A get();
+
+class B {
+public:
+  B(const A &);
+  ~B() {}
+};
+
+// FIXME: Find construction context for the implicit constructor conversion.
+// CHECK: void implicitConstructionConversionFromFunctionValue()
+// CHECK:  1: get
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class implicit_constructor_conver
+// CHECK-NEXT: 3: [B1.2]()
+// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::A)
+// CHECK-NEXT: 5: [B1.4]
+// CHECK-NEXT: 6: [B1.5] (CXXConstructExpr, class implicit_constructor_conversion::B)
+// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, ConstructorConversion, class implicit_constructor_convers
+// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, NoOp, const class implicit_constructor_conversion::B)
+// CHECK-NEXT: 9: [B1.8]
+// CHECK-NEXT:10: const implicit_constructor_conversion::B  = get();
+// CHECK-NEXT:11: [B1.10].~B() (Implicit destructor)
+void implicitConstructionConversionFromFunctionValue() {
+  const B  = get(); // no-crash
+}
+
+} // end namespace implicit_constructor_conversion
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1200,7 +1200,9 @@
   }
   case Stmt::ImplicitCastExprClass: {
 auto *Cast = cast(Child);
-findConstructionContexts(Layer, Cast->getSubExpr());
+// TODO: We need to support CK_ConstructorConversion, maybe other kinds?
+if (Cast->getCastKind() == CK_NoOp)
+  findConstructionContexts(Layer, Cast->getSubExpr());
 break;
   }
   case Stmt::CXXBindTemporaryExprClass: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26350: Keep invalid Switch in the AST

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:823
+  CondExpr->isValueDependent() ||
+  isa(CondExpr);
+  unsigned CondWidth =

It's fragile to assume that the only way you can see an `OpaqueValueExpr` here 
is by it being created in `ActOnStartOfSwitchStmt`. We could tunnel this 
information through in another way, though, such as by tracking a bool in the 
`SwitchStack` in addition to the statement.

However, perhaps it's time to bite the bullet and add actual support for error 
nodes in the AST. For example, we could add a new kind of placeholder type for 
an erroneous expression, and build syntactic expression trees with that type 
when we encounter errors.


https://reviews.llvm.org/D26350



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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Yay! This looks good to me.


https://reviews.llvm.org/D43804



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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 136428.
NoQ added a comment.

Don't inline temporary destructors for now (i.e. keep 
`c++-temp-dtor-inlining=false`, previously it was by default irrelevant and 
arbitrarily set to true). That's because https://reviews.llvm.org/D43791 wasn't 
enough to handle all the problems with smart pointers; some custom reference 
counting pointers produce large inlining stacks that we just refuse to 
traverse. I'd try to address it sooner rather than later and then enable this 
flag as well.

With `c++-temp-dtor-inlining=false` this change seems even more quiet (around 
+27/-24, on roughly the same codebase that produced +20/-35 in 
https://reviews.llvm.org/D42219), and much like the last time it's mostly about 
rearranging large chunks of false positives due to complete lack of support for 
temporaries into smaller groups of false positives due to lack of support for 
something else. This is far from a breakthrough yet - a lot more work needs to 
be done, but neither it is falling apart immediately, and, most importantly, it 
gives hope to address any single problem with a targeted fix, because 
fundamental issues we used to have with temporaries would be mostly gone. So i 
wish to encourage switching to the new mode earlier rather than later (though 
it's always possible to flip the flag back locally in case of any severe 
problems i didn't foresee).


https://reviews.llvm.org/D43804

Files:
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/inlining/temp-dtors-path-notes.cpp
  test/Analysis/lifetime-cfg-output.cpp
  test/Analysis/lifetime-extension.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify -w -std=c++03 %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify -w -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s -std=c++11
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true %s -std=c++11
 
 extern bool clang_analyzer_eval(bool);
 extern bool clang_analyzer_warnIfReached();
Index: test/Analysis/lifetime-extension.cpp
===
--- test/Analysis/lifetime-extension.cpp
+++ test/Analysis/lifetime-extension.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -verify %s
-// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true -DTEMPORARIES -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -DTEMPORARIES -verify %s
 
 void clang_analyzer_eval(bool);
 
Index: test/Analysis/lifetime-cfg-output.cpp
===
--- test/Analysis/lifetime-cfg-output.cpp
+++ test/Analysis/lifetime-cfg-output.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true,cfg-rich-constructors=false -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true,cfg-temporary-dtors=false,cfg-rich-constructors=false -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 extern bool UV;
Index: test/Analysis/inlining/temp-dtors-path-notes.cpp
===
--- test/Analysis/inlining/temp-dtors-path-notes.cpp
+++ test/Analysis/inlining/temp-dtors-path-notes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config cfg-temporary-dtors=true -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -analyzer-output=text -verify %s
 
 namespace test_simple_temporary {
 class C {
Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -13,7 +13,7 @@
 class Foo {
 

[PATCH] D43851: Start setting dllimport/dllexport in setGVProperties

2018-02-28 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

r326397


https://reviews.llvm.org/D43851



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


[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

Per [dcl.type.class.deduct]p1, only the initializing declaration of a variable 
can use a placeholder type. The existing diagnostic was correct in many of the 
modified cases.




Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp:15
 struct B {
-  static A a; // expected-error {{requires an initializer}}
+  static A a;
 };

This should be ill-formed: this is not the initializing declaration of `B::a`.



Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp:17
 };
-extern A x; // expected-error {{requires an initializer}}
+extern A x;

Likewise, this should remain ill-formed.



Comment at: test/Parser/cxx1z-class-template-argument-deduction.cpp:55
 
-  static A x; // expected-error {{declaration of variable 'x' with deduced 
type 'A' requires an initializer}}
+  static A x;
   static constexpr A y = 0;

Likewise.


https://reviews.llvm.org/D38216



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


r326397 - Start setting dllimport/dllexport in setGVProperties.

2018-02-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 28 16:35:47 2018
New Revision: 326397

URL: http://llvm.org/viewvc/llvm-project?rev=326397=rev
Log:
Start setting dllimport/dllexport in setGVProperties.

This is the next step in setting dso_local for COFF.

The patches changes setGVProperties to first set dllimport/dllexport
and changes a few cases that were setting dllimport/dllexport
manually. With this a few more GVs are marked dso_local.

Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
cfe/trunk/test/CodeGenObjC/dllstorage.m
cfe/trunk/test/PCH/dllexport-default-arg-closure.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=326397=326396=326397=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Feb 28 16:35:47 2018
@@ -205,7 +205,7 @@ bool CodeGenModule::TryEmitDefinitionAsA
   }
 
   // Finally, set up the alias with its proper name and attributes.
-  setAliasAttributes(AliasDecl, Alias);
+  SetCommonAttributes(AliasDecl, Alias);
 
   return false;
 }
@@ -227,7 +227,6 @@ llvm::Function *CodeGenModule::codegenCX
   }
 
   setFunctionLinkage(GD, Fn);
-  setFunctionDLLStorageClass(GD, Fn);
 
   CodeGenFunction(*this).GenerateCode(GD, Fn, FnInfo);
   setNonAliasAttributes(GD, Fn);

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=326397=326396=326397=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Wed Feb 28 16:35:47 2018
@@ -433,6 +433,7 @@ public:
   /// base tables.
   virtual void emitVirtualInheritanceTables(const CXXRecordDecl *RD) = 0;
 
+  virtual bool exportThunk() = 0;
   virtual void setThunkLinkage(llvm::Function *Thunk, bool ForVTable,
GlobalDecl GD, bool ReturnAdjustment) = 0;
 

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=326397=326396=326397=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb 28 16:35:47 2018
@@ -247,13 +247,6 @@ llvm::Constant *CodeGenModule::getOrCrea
   if (D.getTLSKind())
 setTLSMode(GV, D);
 
-  if (D.isExternallyVisible()) {
-if (D.hasAttr())
-  GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
-else if (D.hasAttr())
-  GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
-  }
-
   setGVProperties(GV, );
 
   // Make sure the result is of the correct type.

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=326397=326396=326397=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Feb 28 16:35:47 2018
@@ -1035,16 +1035,8 @@ llvm::Value *CGObjCGNU::GetClass(CodeGen
  const ObjCInterfaceDecl *OID) {
   auto *Value =
   GetClassNamed(CGF, OID->getNameAsString(), OID->isWeakImported());
-  if (CGM.getTriple().isOSBinFormatCOFF()) {
-if (auto *ClassSymbol = dyn_cast(Value)) {
-  auto DLLStorage = llvm::GlobalValue::DefaultStorageClass;
-  if (OID->hasAttr())
-DLLStorage = llvm::GlobalValue::DLLExportStorageClass;
-  else if (OID->hasAttr())
-DLLStorage = llvm::GlobalValue::DLLImportStorageClass;
-  ClassSymbol->setDLLStorageClass(DLLStorage);
-}
-  }
+  if (auto *ClassSymbol = dyn_cast(Value))
+CGM.setGVProperties(ClassSymbol, OID);
   return Value;
 }
 
@@ -1061,13 +1053,7 @@ llvm::Value *CGObjCGNU::EmitNSAutoreleas
 if ((VD = dyn_cast(Result)))
   break;
 
-  auto DLLStorage = llvm::GlobalValue::DefaultStorageClass;
-  if (!VD || VD->hasAttr())
-DLLStorage = llvm::GlobalValue::DLLImportStorageClass;
-  else if (VD->hasAttr())
-DLLStorage = llvm::GlobalValue::DLLExportStorageClass;
-
-  ClassSymbol->setDLLStorageClass(DLLStorage);
+  CGM.setGVProperties(ClassSymbol, VD);
 }
   }
   return Value;
@@ -2336,14 +2322,8 @@ void CGObjCGNU::GenerateClass(const ObjC
   NULLPtr, NULLPtr, 0x12L, ClassName.c_str(), nullptr, Zeros[0],

[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-02-28 Thread Amara Emerson via Phabricator via cfe-commits
aemerson added a comment.

Can we clarify the meaning of this option a bit. The doc you've added here is 
saying that `-mno-stack-arg-probe` disables stack probes. Then what does 
`-mstack-arg-probe` mean specifically? Does it mean that only stack probes for 
ABI required reasons are enabled, or probes are done even in cases where the 
ABI doesn't require them? Either way, the doc needs to be clearer on the exact 
purpose.

I'm currently working on enabling stack probes for reasons other than ABI, and 
so if the answer is that this option is only concerned with ABI, we will need 
another option like `-fstack-check`.


Repository:
  rC Clang

https://reviews.llvm.org/D43108



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


r326392 - Pass a GlobalDecl to SetCommonAttributes. NFC.

2018-02-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 28 16:06:55 2018
New Revision: 326392

URL: http://llvm.org/viewvc/llvm-project?rev=326392=rev
Log:
Pass a GlobalDecl to SetCommonAttributes. NFC.

Part of D43900.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=326392=326391=326392=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 28 16:06:55 2018
@@ -1232,8 +1232,8 @@ void CodeGenModule::SetLLVMFunctionAttri
   CreateFunctionTypeMetadata(FD, F);
 }
 
-void CodeGenModule::SetCommonAttributes(const Decl *D,
-llvm::GlobalValue *GV) {
+void CodeGenModule::SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV) {
+  const Decl *D = GD.getDecl();
   if (const auto *ND = dyn_cast_or_null(D))
 setGVProperties(GV, ND);
   else
@@ -1245,7 +1245,7 @@ void CodeGenModule::SetCommonAttributes(
 
 void CodeGenModule::setAliasAttributes(GlobalDecl GD, llvm::GlobalValue *GV) {
   const Decl *D = GD.getDecl();
-  SetCommonAttributes(D, GV);
+  SetCommonAttributes(GD, GV);
 
   // Process the dllexport attribute based on whether the original definition
   // (not necessarily the aliasee) was exported.
@@ -1302,7 +1302,7 @@ bool CodeGenModule::GetCPUAndFeaturesAtt
 void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
   llvm::GlobalObject *GO) {
   const Decl *D = GD.getDecl();
-  SetCommonAttributes(D, GO);
+  SetCommonAttributes(GD, GO);
 
   if (D) {
 if (auto *GV = dyn_cast(GO)) {
@@ -3731,7 +3731,7 @@ void CodeGenModule::emitIFuncDefinition(
   } else
 GIF->setName(MangledName);
 
-  SetCommonAttributes(D, GIF);
+  SetCommonAttributes(GD, GIF);
 }
 
 llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=326392=326391=326392=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Feb 28 16:06:55 2018
@@ -1188,7 +1188,7 @@ public:
   /// Objective-C method, function, global variable).
   ///
   /// NOTE: This should only be called for definitions.
-  void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV);
+  void SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV);
 
   /// Set attributes which must be preserved by an alias. This includes common
   /// attributes (i.e. it includes a call to SetCommonAttributes).


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


r326391 - Inline a trivial function. NFC.

2018-02-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 28 16:00:02 2018
New Revision: 326391

URL: http://llvm.org/viewvc/llvm-project?rev=326391=rev
Log:
Inline a trivial function. NFC.

Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=326391=326390=326391=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Feb 28 16:00:02 2018
@@ -230,7 +230,7 @@ llvm::Function *CodeGenModule::codegenCX
   setFunctionDLLStorageClass(GD, Fn);
 
   CodeGenFunction(*this).GenerateCode(GD, Fn, FnInfo);
-  setFunctionDefinitionAttributes(GD, Fn);
+  setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(MD, Fn);
   return Fn;
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=326391=326390=326391=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 28 16:00:02 2018
@@ -1080,11 +1080,6 @@ llvm::ConstantInt *CodeGenModule::Create
   return llvm::ConstantInt::get(Int64Ty, llvm::MD5Hash(MDS->getString()));
 }
 
-void CodeGenModule::setFunctionDefinitionAttributes(GlobalDecl GD,
-llvm::Function *F) {
-  setNonAliasAttributes(GD, F);
-}
-
 void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
   const CGFunctionInfo ,
   llvm::Function *F) {
@@ -3593,7 +3588,7 @@ void CodeGenModule::EmitGlobalFunctionDe
 
   CodeGenFunction(*this).GenerateCode(D, Fn, FI);
 
-  setFunctionDefinitionAttributes(GD, Fn);
+  setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
 
   if (const ConstructorAttr *CA = D->getAttr())

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=326391=326390=326391=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Feb 28 16:00:02 2018
@@ -1182,9 +1182,6 @@ public:
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
 
-  /// Set attributes for a global definition.
-  void setFunctionDefinitionAttributes(GlobalDecl GD, llvm::Function *F);
-
   llvm::GlobalValue *GetGlobalValue(StringRef Ref);
 
   /// Set attributes which are common to any form of a global definition 
(alias,


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


r326388 - Pass a GlobalDecl to setNonAliasAttributes. NFC.

2018-02-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 28 15:54:23 2018
New Revision: 326388

URL: http://llvm.org/viewvc/llvm-project?rev=326388=rev
Log:
Pass a GlobalDecl to setNonAliasAttributes. NFC.

Also part of D43900.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=326388=326387=326388=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 28 15:54:23 2018
@@ -1082,7 +1082,7 @@ llvm::ConstantInt *CodeGenModule::Create
 
 void CodeGenModule::setFunctionDefinitionAttributes(GlobalDecl GD,
 llvm::Function *F) {
-  setNonAliasAttributes(GD.getDecl(), F);
+  setNonAliasAttributes(GD, F);
 }
 
 void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
@@ -1304,8 +1304,9 @@ bool CodeGenModule::GetCPUAndFeaturesAtt
   return AddedAttr;
 }
 
-void CodeGenModule::setNonAliasAttributes(const Decl *D,
+void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
   llvm::GlobalObject *GO) {
+  const Decl *D = GD.getDecl();
   SetCommonAttributes(D, GO);
 
   if (D) {
@@ -1350,7 +1351,7 @@ void CodeGenModule::SetInternalFunctionA
 
   F->setLinkage(llvm::Function::InternalLinkage);
 
-  setNonAliasAttributes(D, F);
+  setNonAliasAttributes(GD, F);
 }
 
 static void setLinkageForGV(llvm::GlobalValue *GV,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=326388=326387=326388=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Feb 28 15:54:23 2018
@@ -1277,7 +1277,7 @@ private:
 
   bool GetCPUAndFeaturesAttributes(const Decl *D,
llvm::AttrBuilder );
-  void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
+  void setNonAliasAttributes(GlobalDecl GD, llvm::GlobalObject *GO);
 
   /// Set function attributes for a function declaration.
   void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,


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


[clang-tools-extra] r326386 - [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 28 15:47:15 2018
New Revision: 326386

URL: http://llvm.org/viewvc/llvm-project?rev=326386=rev
Log:
[clang-tidy] Another batch of checks to rename from misc- to bugprone-.

Summary:
clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon
clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare
clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments
clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor 
--check_class_name UndelegatedConstructor

Reviewers: hokein, sammccall, aaron.ballman

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

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.h
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousStringCompareCheck.h
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/SwappedArgumentsCheck.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SwappedArgumentsCheck.h
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/UndelegatedConstructorCheck.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/UndelegatedConstructorCheck.h
  - copied, changed from r326384, 
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-semicolon.rst
  - copied, changed from r326384, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
  - copied, changed from r326384, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-string-compare.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-swapped-arguments.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-undelegated-constructor.rst
  - copied, changed from r326384, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-undelegated-constructor.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-semicolon.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-string-compare.c
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-string-compare.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-swapped-arguments.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-swapped-arguments.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-undelegated-constructor-cxx98.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-undelegated-constructor.cpp
  - copied, changed from r326384, 
clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SwappedArgumentsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-string-compare.rst

r326385 - Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.

2018-02-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 28 15:46:35 2018
New Revision: 326385

URL: http://llvm.org/viewvc/llvm-project?rev=326385=rev
Log:
Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.

This just reduces the noise in a followup patch.

Part of D43900.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=326385=326384=326385=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Feb 28 15:46:35 2018
@@ -1659,7 +1659,7 @@ CodeGenFunction::GenerateCopyHelperFunct
   false,
   false);
 
-  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
@@ -1837,7 +1837,7 @@ CodeGenFunction::GenerateDestroyHelperFu
   nullptr, SC_Static,
   false, false);
 
-  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getLocStart()};
@@ -2119,7 +2119,7 @@ generateByrefCopyHelper(CodeGenFunction
   SC_Static,
   false, false);
 
-  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+  CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   CGF.StartFunction(FD, R, Fn, FI, args);
 
@@ -2193,7 +2193,7 @@ generateByrefDisposeHelper(CodeGenFuncti
   SC_Static,
   false, false);
 
-  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+  CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   CGF.StartFunction(FD, R, Fn, FI, args);
 

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=326385=326384=326385=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Feb 28 15:46:35 2018
@@ -312,7 +312,7 @@ llvm::Function *CodeGenModule::CreateGlo
   Fn->setSection(Section);
   }
 
-  SetInternalFunctionAttributes(nullptr, Fn, FI);
+  SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   Fn->setCallingConv(getRuntimeCC());
 

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=326385=326384=326385=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Feb 28 15:46:35 2018
@@ -3243,7 +3243,7 @@ CodeGenFunction::GenerateObjCAtomicSette
"__assign_helper_atomic_property_",
());
 
-  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   
@@ -3324,8 +3324,8 @@ CodeGenFunction::GenerateObjCAtomicGette
   llvm::Function *Fn =
   llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage,
  "__copy_helper_atomic_property_", ());
-  
-  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
 
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=326385=326384=326385=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Feb 28 15:46:35 2018
@@ -1209,7 +1209,7 @@ emitCombinerOrInitializer(CodeGenModule
   auto *Fn = llvm::Function::Create(
   FnTy, llvm::GlobalValue::InternalLinkage,
   IsCombiner ? ".omp_combiner." : ".omp_initializer.", ());
-  CGM.SetInternalFunctionAttributes(/*D=*/nullptr, Fn, FnInfo);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FnInfo);
   Fn->removeFnAttr(llvm::Attribute::NoInline);
   Fn->removeFnAttr(llvm::Attribute::OptimizeNone);
   Fn->addFnAttr(llvm::Attribute::AlwaysInline);
@@ -2804,7 +2804,7 @@ static llvm::Value 

[PATCH] D43870: [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh marked an inline comment as done.
alexfh added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- The 'misc-undelegated-constructor' check was renamed to 
`bugprone-undelegated-constructor
+  
`_

Eugene.Zelenko wrote:
> Please sort checks alphabetically. Will be also good idea to move renamed 
> checks after new checks/modules.
I've sorted the entries manually. I hope I can change the rename_check.py 
script to insert new notes into the right place in the list.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43870



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


[PATCH] D43868: Rename more checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE326384: Rename more checks from misc- to bugprone-. 
(authored by alexfh, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43868?vs=136277=136412#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43868

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tidy/bugprone/StringIntegerAssignmentCheck.h
  clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.h
  clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tidy/bugprone/SuspiciousEnumUsageCheck.h
  clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tidy/bugprone/SuspiciousMissingCommaCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.h
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
  clang-tidy/misc/SuspiciousEnumUsageCheck.h
  clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
  clang-tidy/misc/SuspiciousMissingCommaCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-string-integer-assignment.rst
  docs/clang-tidy/checks/bugprone-string-literal-with-embedded-nul.rst
  docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
  docs/clang-tidy/checks/bugprone-suspicious-missing-comma.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-integer-assignment.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  test/clang-tidy/bugprone-string-integer-assignment.cpp
  test/clang-tidy/bugprone-string-literal-with-embedded-nul.cpp
  test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
  test/clang-tidy/bugprone-suspicious-enum-usage.cpp
  test/clang-tidy/bugprone-suspicious-missing-comma.cpp
  test/clang-tidy/misc-string-integer-assignment.cpp
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
  test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
  test/clang-tidy/misc-suspicious-enum-usage.cpp
  test/clang-tidy/misc-suspicious-missing-comma.cpp

Index: docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
===
--- docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
+++ docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
@@ -0,0 +1,78 @@
+.. title:: clang-tidy - bugprone-suspicious-enum-usage
+
+bugprone-suspicious-enum-usage
+==
+
+The checker detects various cases when an enum is probably misused (as a bitmask
+).
+  
+1. When "ADD" or "bitwise OR" is used between two enum which come from different
+   types and these types value ranges are not disjoint.
+
+The following cases will be investigated only using :option:`StrictMode`. We 
+regard the enum as a (suspicious)
+bitmask if the three conditions below are true at the same time:
+
+* at most half of the elements of the enum are non pow-of-2 numbers (because of
+  short enumerations)
+* there is another non pow-of-2 number than the enum constant representing all
+  choices (the result "bitwise OR" operation of all enum elements)
+* enum type variable/enumconstant is used as an argument of a `+` or "bitwise OR
+  " operator
+
+So whenever the non pow-of-2 element is used as a bitmask element we diagnose a
+misuse and give a warning.
+
+2. Investigating the right hand side of `+=` and `|=` operator.
+3. Check only the enum value side of a `|` and `+` operator if one of them is not
+   enum val.
+4. Check both side of `|` or `+` operator where the enum values are from the
+   same enum type.
+
+Examples:
+
+.. code-block:: c++
+
+  enum { A, B, C };
+  enum { D, E, F = 5 };
+  enum { G = 10, H = 11, I = 12 };
+  
+  unsigned flag;
+  flag =
+  A |
+  H; // OK, disjoint value intervalls in the enum types ->probably good use.
+  flag = B | F; // Warning, have common values so they are probably misused.
+  
+  // Case 2:
+  enum Bitmask {
+A = 0,
+B = 1,
+C = 2,
+D = 4,
+E = 8,
+F = 16,
+G = 31 // OK, real bitmask.
+  };
+  
+  enum Almostbitmask {
+AA = 0,
+BB = 1,
+CC = 2,
+DD = 4,
+EE = 8,
+FF = 16,
+GG // Problem, forgot to initialize.
+  };
+  
+  unsigned flag = 0;
+  flag |= E; // OK.
+  flag |=
+  EE; // Warning at the decl, and note that it was used here as a bitmask.
+
+Options
+---
+.. option:: StrictMode
+
+   Default value: 0.
+   When non-null the suspicious bitmask usage will be investigated additionally
+   to the different enum usage check.
Index: docs/clang-tidy/checks/list.rst

[PATCH] D43868: Rename more checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326384: Rename more checks from misc- to bugprone-. 
(authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43868?vs=136277=136411#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43868

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.h
  
clang-tools-extra/trunk/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.h
  clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousEnumUsageCheck.h
  clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMissingCommaCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-string-integer-assignment.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-string-literal-with-embedded-nul.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-missing-comma.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-integer-assignment.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-literal-with-embedded-nul.cpp
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-missing-comma.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp
  
clang-tools-extra/trunk/test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-missing-comma.cpp

Index: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -28,7 +28,11 @@
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
 #include "StringConstructorCheck.h"
+#include "StringIntegerAssignmentCheck.h"
+#include "StringLiteralWithEmbeddedNulCheck.h"
+#include "SuspiciousEnumUsageCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
+#include "SuspiciousMissingCommaCheck.h"
 #include "ThrowKeywordMissingCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UseAfterMoveCheck.h"
@@ -77,8 +81,16 @@
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(
 "bugprone-string-constructor");
+CheckFactories.registerCheck(
+"bugprone-string-integer-assignment");
+CheckFactories.registerCheck(
+"bugprone-string-literal-with-embedded-nul");
+CheckFactories.registerCheck(
+"bugprone-suspicious-enum-usage");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
+CheckFactories.registerCheck(
+"bugprone-suspicious-missing-comma");
 CheckFactories.registerCheck(
 "bugprone-throw-keyword-missing");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.h

[clang-tools-extra] r326384 - Rename more checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 28 15:30:29 2018
New Revision: 326384

URL: http://llvm.org/viewvc/llvm-project?rev=326384=rev
Log:
Rename more checks from misc- to bugprone-.

Summary:
clang-tidy/rename_check.py {misc,bugprone}-string-integer-assignment
clang-tidy/rename_check.py {misc,bugprone}-string-literal-with-embedded-nul
clang-tidy/rename_check.py {misc,bugprone}-suspicious-enum-usage
clang-tidy/rename_check.py {misc,bugprone}-suspicious-missing-comma

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.h
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h

clang-tools-extra/trunk/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp

clang-tools-extra/trunk/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.h
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousEnumUsageCheck.h
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMissingCommaCheck.h
  - copied, changed from r326365, 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-string-integer-assignment.rst
  - copied, changed from r326365, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-integer-assignment.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-string-literal-with-embedded-nul.rst
  - copied, changed from r326365, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
  - copied, changed from r326365, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-enum-usage.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-suspicious-missing-comma.rst
  - copied, changed from r326365, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/test/clang-tidy/misc-string-integer-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-string-literal-with-embedded-nul.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-enum-usage.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-suspicious-missing-comma.cpp
  - copied, changed from r326365, 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-missing-comma.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.h

clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.h
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-integer-assignment.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-enum-usage.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst

[PATCH] D42755: [libcxx] Fix last_write_time tests for filesystems that don't support very small times.

2018-02-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326383: [libcxx] Fix last_write_time test for filesystems 
that dont support very small… (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42755?vs=135003=136410#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42755

Files:
  
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp


Index: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -116,12 +116,31 @@
 return !ec && new_write_time > max_sec - 1;
 }
 
+bool TestSupportsMinTime() {
+using namespace std::chrono;
+using Lim = std::numeric_limits;
+auto min_sec = 
duration_cast(file_time_type::min().time_since_epoch()).count();
+if (min_sec < Lim::min()) return false;
+std::error_code ec;
+std::time_t old_write_time, new_write_time;
+{ // WARNING: Do not assert in this scope.
+  scoped_test_env env;
+  const path file = env.create_file("file", 42);
+  old_write_time = LastWriteTime(file);
+  file_time_type tp = file_time_type::min();
+  fs::last_write_time(file, tp, ec);
+  new_write_time = LastWriteTime(file);
+}
+return !ec && new_write_time < min_sec + 1;
+}
+
 #if defined(__clang__)
 #pragma clang diagnostic pop
 #endif
 
 static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
 static const bool SupportsMaxTime = TestSupportsMaxTime();
+static const bool SupportsMinTime = TestSupportsMinTime();
 
 } // end namespace
 
@@ -140,14 +159,17 @@
 // (B) 'tp' is non-negative or the filesystem supports negative times.
 // (C) 'tp' is not 'file_time_type::max()' or the filesystem supports the max
 // value.
+// (D) 'tp' is not 'file_time_type::min()' or the filesystem supports the min
+// value.
 inline bool TimeIsRepresentableByFilesystem(file_time_type tp) {
 using namespace std::chrono;
 using Lim = std::numeric_limits;
 auto sec = duration_cast(tp.time_since_epoch()).count();
 auto microsec = duration_cast(tp.time_since_epoch()).count();
 if (sec < Lim::min() || sec > Lim::max())   return false;
 else if (microsec < 0 && !SupportsNegativeTimes) return false;
 else if (tp == file_time_type::max() && !SupportsMaxTime) return false;
+else if (tp == file_time_type::min() && !SupportsMinTime) return false;
 return true;
 }
 
@@ -355,20 +377,20 @@
 TEST_CHECK(!ec);
 TEST_CHECK(tt >= new_time);
 TEST_CHECK(tt < new_time + Sec(1));
-}
 
-ec = GetTestEC();
-last_write_time(p, Clock::now());
+ec = GetTestEC();
+last_write_time(p, Clock::now());
 
-new_time = file_time_type::min() + MicroSec(1);
+new_time = file_time_type::min() + MicroSec(1);
 
-last_write_time(p, new_time, ec);
-tt = last_write_time(p);
+last_write_time(p, new_time, ec);
+tt = last_write_time(p);
 
-if (TimeIsRepresentableByFilesystem(new_time)) {
-TEST_CHECK(!ec);
-TEST_CHECK(tt >= new_time);
-TEST_CHECK(tt < new_time + Sec(1));
+if (TimeIsRepresentableByFilesystem(new_time)) {
+TEST_CHECK(!ec);
+TEST_CHECK(tt >= new_time);
+TEST_CHECK(tt < new_time + Sec(1));
+}
 }
 }
 


Index: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -116,12 +116,31 @@
 return !ec && new_write_time > max_sec - 1;
 }
 
+bool TestSupportsMinTime() {
+using namespace std::chrono;
+using Lim = std::numeric_limits;
+auto min_sec = duration_cast(file_time_type::min().time_since_epoch()).count();
+if (min_sec < Lim::min()) return false;
+std::error_code ec;
+std::time_t old_write_time, new_write_time;
+{ // WARNING: Do not assert in this scope.
+  scoped_test_env env;
+  const path file = env.create_file("file", 42);
+  old_write_time = LastWriteTime(file);
+  file_time_type tp = file_time_type::min();
+  fs::last_write_time(file, tp, ec);
+  new_write_time = LastWriteTime(file);
+}
+return !ec && new_write_time < min_sec + 1;
+}
+
 #if defined(__clang__)
 #pragma clang diagnostic pop
 

[libcxx] r326383 - [libcxx] Fix last_write_time test for filesystems that don't support very small times.

2018-02-28 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Feb 28 15:27:40 2018
New Revision: 326383

URL: http://llvm.org/viewvc/llvm-project?rev=326383=rev
Log:
[libcxx] Fix last_write_time test for filesystems that don't support very small 
times.

APFS minimum supported file write time is -2^63 nanoseconds, which doesn't go
as far as `file_time_type::min()` that is equal to -2^63 microseconds on macOS.

This change doesn't affect filesystems that support `file_time_type` range only
for in-memory file time representation but not for on-disk representation. Such
filesystems are considered as `SupportsMinTime`.

rdar://problem/35865151

Reviewers: EricWF, Hahnfeld

Subscribers: jkorous-apple, mclow.lists, cfe-commits, christof

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


Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=326383=326382=326383=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Wed Feb 28 15:27:40 2018
@@ -116,12 +116,31 @@ bool TestSupportsMaxTime() {
 return !ec && new_write_time > max_sec - 1;
 }
 
+bool TestSupportsMinTime() {
+using namespace std::chrono;
+using Lim = std::numeric_limits;
+auto min_sec = 
duration_cast(file_time_type::min().time_since_epoch()).count();
+if (min_sec < Lim::min()) return false;
+std::error_code ec;
+std::time_t old_write_time, new_write_time;
+{ // WARNING: Do not assert in this scope.
+  scoped_test_env env;
+  const path file = env.create_file("file", 42);
+  old_write_time = LastWriteTime(file);
+  file_time_type tp = file_time_type::min();
+  fs::last_write_time(file, tp, ec);
+  new_write_time = LastWriteTime(file);
+}
+return !ec && new_write_time < min_sec + 1;
+}
+
 #if defined(__clang__)
 #pragma clang diagnostic pop
 #endif
 
 static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
 static const bool SupportsMaxTime = TestSupportsMaxTime();
+static const bool SupportsMinTime = TestSupportsMinTime();
 
 } // end namespace
 
@@ -140,6 +159,8 @@ static const bool SupportsMaxTime = Test
 // (B) 'tp' is non-negative or the filesystem supports negative times.
 // (C) 'tp' is not 'file_time_type::max()' or the filesystem supports the max
 // value.
+// (D) 'tp' is not 'file_time_type::min()' or the filesystem supports the min
+// value.
 inline bool TimeIsRepresentableByFilesystem(file_time_type tp) {
 using namespace std::chrono;
 using Lim = std::numeric_limits;
@@ -148,6 +169,7 @@ inline bool TimeIsRepresentableByFilesys
 if (sec < Lim::min() || sec > Lim::max())   return false;
 else if (microsec < 0 && !SupportsNegativeTimes) return false;
 else if (tp == file_time_type::max() && !SupportsMaxTime) return false;
+else if (tp == file_time_type::min() && !SupportsMinTime) return false;
 return true;
 }
 
@@ -355,20 +377,20 @@ TEST_CASE(test_write_min_time)
 TEST_CHECK(!ec);
 TEST_CHECK(tt >= new_time);
 TEST_CHECK(tt < new_time + Sec(1));
-}
 
-ec = GetTestEC();
-last_write_time(p, Clock::now());
+ec = GetTestEC();
+last_write_time(p, Clock::now());
 
-new_time = file_time_type::min() + MicroSec(1);
+new_time = file_time_type::min() + MicroSec(1);
 
-last_write_time(p, new_time, ec);
-tt = last_write_time(p);
+last_write_time(p, new_time, ec);
+tt = last_write_time(p);
 
-if (TimeIsRepresentableByFilesystem(new_time)) {
-TEST_CHECK(!ec);
-TEST_CHECK(tt >= new_time);
-TEST_CHECK(tt < new_time + Sec(1));
+if (TimeIsRepresentableByFilesystem(new_time)) {
+TEST_CHECK(!ec);
+TEST_CHECK(tt >= new_time);
+TEST_CHECK(tt < new_time + Sec(1));
+}
 }
 }
 


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


[PATCH] D43908: [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-02-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.

Ugh, really not a fan of this change.


Repository:
  rC Clang

https://reviews.llvm.org/D43908



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


[PATCH] D43908: [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-02-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D43908



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


[PATCH] D42755: [libcxx] Fix last_write_time tests for filesystems that don't support very small times.

2018-02-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I am going to commit this change as I've addressed the review comments. If 
anybody has anything else to add, we can discuss that in post-commit review.


https://reviews.llvm.org/D42755



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


[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-02-28 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule added a comment.

Thanks for your feedback, they are very precious to me!




Comment at: 
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h:45
+/// \brief Map mapping file name to AtomicChange targeting that file.
+typedef llvm::DenseMap
+FileToChangeMap;

ioeric wrote:
> I would expect this to be a map from files to a group of AtomicChanges (e.g. 
> `std::vector`). In general, a single AtomicChange contains 
> changes around a single code location which are likely to conflict with each 
> other, and either all changes or no change is applied. A file usually 
> corresponds to a set of atomic changes. 
> 
> Intuitively, I think clang-apply-replacements should simple gather a set of 
> atomic changes for each file and let `applyAtomicChanges` handle the 
> conflicts, but its current behavior is to skip conflicting replacements and 
> keep applying other replacements. This is not ideal, but I guess I understand 
> where this came from, and we might not be able to fix this in this patch 
> since most tools produce replacements instead of AtomicChange.
> 
> I would still suggest make this a map something like `llvm::DenseMap clang::FileEntry *, std::vector>`. To preserve the 
> current behavior (i.e. skip conflicts), when you group all replacements for a 
> single file, you would still put all replacements into a single AtomicChange, 
> but when you actually put the change into the map, you put it as a vector of 
> a single change.
I got your point. I will update the patch this way.



Comment at: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp:207
+  llvm::DenseMap>
+  GroupedReplacements;
+

ioeric wrote:
> I don't think we need to do the deduplication here anymore. AtomicChange 
> handles duplicates for you. I think all you need to do here is to group 
> replacements by files and later convert replacements to atomic changes.
I think I wrongly use AtomicChange somewhere because it doesn't deduplicate 
same replacement automatically.
For exemple, in the test suite, basic test defines 2 time the same replacement 
(adding 'override ' at offset 148) and I do not manage to avoid AtomicChange to 
add 'override override '. This is why I have kept the deduplicate step.



Comment at: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp:279
+  if (!NewCode) {
+errs() << "Failed to apply fixes on " << File << "\n";
+return false;

ioeric wrote:
> You should handle the error in `llvm::Expected`. You could convert it to 
> string and add to the error message with 
> `llvm::toString(NewCode.takeError())`. It would be nice if we could have a 
> test case for such cases.
I will use `llvm::Expected` as you suggest.
Do you have some ideas to made a test failed at this level?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43764



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


[PATCH] D43851: Start setting dllimport/dllexport in setGVProperties

2018-02-28 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Seems reasonable to me.


https://reviews.llvm.org/D43851



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


[PATCH] D43911: [AMDGPU] Clean up old address space mapping and fix constant address space value

2018-02-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: t-tye, b-sumner, arsenm.
Herald added subscribers: tpr, dstuttard, nhaehnle, wdng, kzhuravl.

https://reviews.llvm.org/D43911

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Index: test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
===
--- test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -78,17 +78,17 @@
 // X86: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = internal global [2 x i32] zeroinitializer, align 4
 // X86: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = internal constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4
 // AMDGCN: @_ZN15partly_constant1kE = addrspace(1) global i32 0, align 4
-// AMDGCN: @_ZN15partly_constant2ilE = addrspace(2) global {{.*}} null, align 8
-// AMDGCN: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal addrspace(2) global {{.*}} zeroinitializer, align 8
-// AMDGCN: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = internal addrspace(2) global [3 x {{.*}}] zeroinitializer, align 8
-// AMDGCN: @[[PARTLY_CONSTANT_FIRST:_ZGRN15partly_constant2ilE.*]] = internal addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4
-// AMDGCN: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = internal addrspace(2) global [2 x i32] zeroinitializer, align 4
-// AMDGCN: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = internal addrspace(2) constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4
+// AMDGCN: @_ZN15partly_constant2ilE = addrspace(4) global {{.*}} null, align 8
+// AMDGCN: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal addrspace(4) global {{.*}} zeroinitializer, align 8
+// AMDGCN: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = internal addrspace(4) global [3 x {{.*}}] zeroinitializer, align 8
+// AMDGCN: @[[PARTLY_CONSTANT_FIRST:_ZGRN15partly_constant2ilE.*]] = internal addrspace(4) constant [3 x i32] [i32 1, i32 2, i32 3], align 4
+// AMDGCN: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = internal addrspace(4) global [2 x i32] zeroinitializer, align 4
+// AMDGCN: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = internal addrspace(4) constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4
 
 // X86: @[[REFTMP1:.*]] = private constant [2 x i32] [i32 42, i32 43], align 4
 // X86: @[[REFTMP2:.*]] = private constant [3 x %{{.*}}] [%{{.*}} { i32 1 }, %{{.*}} { i32 2 }, %{{.*}} { i32 3 }], align 4
-// AMDGCN: @[[REFTMP1:.*]] = private addrspace(2) constant [2 x i32] [i32 42, i32 43], align 4
-// AMDGCN: @[[REFTMP2:.*]] = private addrspace(2) constant [3 x %{{.*}}] [%{{.*}} { i32 1 }, %{{.*}} { i32 2 }, %{{.*}} { i32 3 }], align 4
+// AMDGCN: @[[REFTMP1:.*]] = private addrspace(4) constant [2 x i32] [i32 42, i32 43], align 4
+// AMDGCN: @[[REFTMP2:.*]] = private addrspace(4) constant [3 x %{{.*}}] [%{{.*}} { i32 1 }, %{{.*}} { i32 2 }, %{{.*}} { i32 3 }], align 4
 
 // CHECK: appending global
 
@@ -518,7 +518,7 @@
 // CHECK-LABEL: @_ZN9B197730102f1Ev
 testcase a{{"", ENUM_CONSTANT}};
 // X86: store %"struct.B19773010::pair"* getelementptr inbounds ([1 x %"struct.B19773010::pair"], [1 x %"struct.B19773010::pair"]* bitcast ([1 x { i8*, i32 }]* @.ref.tmp{{.*}} to [1 x %"struct.B19773010::pair"]*), i64 0, i64 0), %"struct.B19773010::pair"** %{{.*}}, align 8
-// AMDGCN: store %"struct.B19773010::pair"* getelementptr inbounds ([1 x %"struct.B19773010::pair"], [1 x %"struct.B19773010::pair"]* addrspacecast{{.*}} bitcast ([1 x { i8*, i32 }] addrspace(2)* @.ref.tmp{{.*}} to [1 x %"struct.B19773010::pair"] addrspace(2)*){{.*}}, i64 0, i64 0), %"struct.B19773010::pair"** %{{.*}}, align 8
+// AMDGCN: store %"struct.B19773010::pair"* getelementptr inbounds ([1 x %"struct.B19773010::pair"], [1 x %"struct.B19773010::pair"]* addrspacecast{{.*}} bitcast ([1 x { i8*, i32 }] addrspace(4)* @.ref.tmp{{.*}} to [1 x %"struct.B19773010::pair"] addrspace(4)*){{.*}}, i64 0, i64 0), %"struct.B19773010::pair"** %{{.*}}, align 8
   }
   void f2() {
 // CHECK-LABEL: @_ZN9B197730102f2Ev
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -28,23 +28,12 @@
   static const Builtin::Info BuiltinInfo[];
   static const char *const GCCRegNames[];
 
-  struct LLVM_LIBRARY_VISIBILITY AddrSpace {
-unsigned Generic, Global, Local, Constant, Private;
-AddrSpace(bool IsGenericZero_ = false) {
-  if (IsGenericZero_) {
-Generic = 0;
-Global = 1;
-Local = 3;
-Constant = 2;
-Private = 5;
-  } else {
-Generic = 4;
-Global = 1;
-Local = 3;
-Constant = 2;
-Private = 0;
-  }
-}
+  enum AddrSpace {

r326373 - [hwasan] update the asm snippet in the docs to match the current default behaviour

2018-02-28 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed Feb 28 13:58:19 2018
New Revision: 326373

URL: http://llvm.org/viewvc/llvm-project?rev=326373=rev
Log:
[hwasan] update the asm snippet in the docs to match the current default 
behaviour

Modified:
cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst

Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=326373=326372=326373=diff
==
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original)
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Wed Feb 28 
13:58:19 2018
@@ -61,8 +61,6 @@ verifies the tags. Currently, the follow
   14:  00 00 40 b9 ldr w0, [x0] // original load
   18:  c0 03 5f d6 ret 
   1c:  40 20 40 d4 hlt #0x102   // halt
-  20:  00 00 40 b9 ldr w0, [x0] // original load
-  24:  c0 03 5f d6 ret
 
 
 Alternatively, memory accesses are prefixed with a function call.


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


[PATCH] D43902: [clang-format] Don't detect C++11 attribute specifiers as ObjC

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:346
+  bool parseCpp11AttributeSpecifier(FormatToken *Tok) {
+if (!Style.isCpp()) return false;
+if (!Tok || !Tok->startsSequence(tok::l_square, tok::l_square))

aaron.ballman wrote:
> C can use this syntax as well with `-fdouble-square-bracket-attributes`, 
> which would be good to also support.
Ah, good to know. As far as I know, `clang-format` doesn't actually distinguish 
between C and C++ (or Objective-C and Objective-C++).

In this case, `isCpp()` returns true for all of C, C++, Objective-C, and 
Objective-C++:

https://github.com/llvm-mirror/clang/blob/master/include/clang/Format/Format.h#L1229


Repository:
  rC Clang

https://reviews.llvm.org/D43902



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


[PATCH] D43908: [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-02-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: efriedma, compnerd.

This fixes using the ms_struct attribute together with long double on e.g. 
x86-32 linux.


Repository:
  rC Clang

https://reviews.llvm.org/D43908

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/CodeGen/ms_struct-long-double.c


Index: test/CodeGen/ms_struct-long-double.c
===
--- /dev/null
+++ test/CodeGen/ms_struct-long-double.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-gnu 
-fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts %s 
| FileCheck %s
+
+struct ldb_struct {
+  char c;
+  long double ldb;
+} __attribute__((__ms_struct__));
+
+struct ldb_struct a;
+
+// CHECK: 0 | struct ldb_struct
+// CHECK-NEXT:0 |   char c
+// CHECK-NEXT:4 |   long double ldb
+// CHECK-NEXT:  | [sizeof=16, align=4]
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1754,8 +1754,8 @@
 CharUnits TypeSize = Context.getTypeSizeInChars(BTy);
 assert(
 (llvm::isPowerOf2_64(TypeSize.getQuantity()) ||
- Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
-"Non PowerOf2 size outside of GNU mode");
+ !Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment()) 
&&
+"Non PowerOf2 size in MSVC mode");
 if (TypeSize > FieldAlign &&
 llvm::isPowerOf2_64(TypeSize.getQuantity()))
   FieldAlign = TypeSize;


Index: test/CodeGen/ms_struct-long-double.c
===
--- /dev/null
+++ test/CodeGen/ms_struct-long-double.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-gnu -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts %s | FileCheck %s
+
+struct ldb_struct {
+  char c;
+  long double ldb;
+} __attribute__((__ms_struct__));
+
+struct ldb_struct a;
+
+// CHECK: 0 | struct ldb_struct
+// CHECK-NEXT:0 |   char c
+// CHECK-NEXT:4 |   long double ldb
+// CHECK-NEXT:  | [sizeof=16, align=4]
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1754,8 +1754,8 @@
 CharUnits TypeSize = Context.getTypeSizeInChars(BTy);
 assert(
 (llvm::isPowerOf2_64(TypeSize.getQuantity()) ||
- Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
-"Non PowerOf2 size outside of GNU mode");
+ !Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment()) &&
+"Non PowerOf2 size in MSVC mode");
 if (TypeSize > FieldAlign &&
 llvm::isPowerOf2_64(TypeSize.getQuantity()))
   FieldAlign = TypeSize;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D43842#1022546, @rjmccall wrote:

> Okay.  In that case, this seems correct, although it seems to me that perhaps 
> `inalloca` is not actually orthogonal to anything else.  In fact, it seems to 
> me that maybe `inalloca` ought to just be a bit on the CGFunctionInfo and the 
> individual ABIInfos should be left alone.


I don't think this is a good idea, since when inalloca mixes with `__thiscall` 
and `__fastcall`, register parameters are still passed directly. Consider:

  struct S {
S();
S(const S &);
int x;
void thiscall_byval(S o);
  };
  void S::thiscall_byval(S o) {}
  int __fastcall fastcall_byval(int x, int y, S o) { return x + y; }
  
  $ clang -S t.cpp -emit-llvm -m32 -o - | grep define
  define dso_local x86_thiscallcc void 
@"\01?thiscall_byval@S@@QAEXU1@@Z"(%struct.S* %this, <{ %struct.S }>* inalloca) 
#0 align 2 {
  define dso_local x86_fastcallcc i32 @"\01?fastcall_byval@@YIHHHUS@@@Z"(i32 
inreg %x, i32 inreg %y, <{ %struct.S }>* inalloca) #0 {

So sometimes the sret parameter is not in the inalloca pack:

  S __fastcall fastcall_sret(int x, int y, S o) { return o; }
  define dso_local x86_fastcallcc void 
@"\01?fastcall_sret@@YI?AUS@@HHU1@@Z"(%struct.S* inreg noalias sret 
%agg.result, i32 inreg %x, <{ i32, %struct.S }>* inalloca)

I think the long term way to clean this up is to use separate allocations for 
each argument, and use tokens to prevent the middle end from messing up the 
SESE region between the argument allocation point and the call that consumes 
the allocations.

To call foo, the IR would look like:

  void foo(int x, S y, int z, S w);
  ..
  foo(1, S(2), 3, S(4));
  ...
  ; setup w
  %w.token = call token @llvm.allocarg(i32 4)
  %w.addr = call %S* @llvm.argaddr(token %w.token)
  call void @S_ctor(%S* %w.addr, i32 4)
  ; setup y
  %y.token = call token @llvm.allocarg(i32 4)
  %y.addr = call %S* @llvm.argaddr(token %y.token)
  call void @S_ctor(%S* %y.addr, i32 2)
  ; do the call, consume the tokens
  call void @foo(i32 1, %S* inalloca %y.addr, i32 3, %S* inalloca %w.addr) 
"allocargs"[token %w.token, token %y.token]

The tokens would make it illegal to tail merge two calls to foo in an if/else 
diamond with PHIs.

It would also mean that all of this Obj-C IRGen code can go back to assuming 
that pointers are passed directly, because now the presence of one 
non-trivially copyable struct doesn't affect the ABIInfo of every other 
argument.

I am concerned about what happens in evil code like:

foo(({ goto abort_call; 0 }), S(2), 3, S(4));
  abort_call:

In this case, control flow breaks out of expression evaluation, and we never 
deallocate the stack memory for the call. We'd need some way to clean that up, 
perhaps with a cleanup.

This would all be a lot easier if LLVM IR had scopes and it wasn't all just 
basic block soup. Just saying.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-28 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule updated this revision to Diff 136389.
jdemeule added a comment.

Update after review.


https://reviews.llvm.org/D43500

Files:
  unittests/clang-tidy/CMakeLists.txt
  unittests/clang-tidy/ClangTidyTest.h
  unittests/clang-tidy/ModernizerModuleTest.cpp

Index: unittests/clang-tidy/ModernizerModuleTest.cpp
===
--- /dev/null
+++ unittests/clang-tidy/ModernizerModuleTest.cpp
@@ -0,0 +1,92 @@
+#include "ClangTidyTest.h"
+#include "modernize/UseDefaultMemberInitCheck.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tidy::modernize;
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+TEST(UseDefaultMemberInitCheckTest, NoChanges) {
+  EXPECT_NO_CHANGES(
+  UseDefaultMemberInitCheck,
+  "struct S { S() = default; bool a_ = false; bool b_ = false; };");
+  EXPECT_NO_CHANGES(UseDefaultMemberInitCheck, "struct S { S() : a_(true), "
+   "b_(true) {} bool a_{false}; "
+   "bool b_{false}; };");
+}
+
+TEST(UseDefaultMemberInitCheckTest, Basic) {
+  EXPECT_EQ("struct S {\n"
+"  S() {}\n"
+"  bool a_{false};\n"
+"};",
+runCheckAndFormatOnCode(
+"struct S { S() : a_(false) {} bool a_; };"));
+}
+
+TEST(UseDefaultMemberInitCheckTest, SeveralInitializers) {
+  EXPECT_EQ(
+  "struct S {\n"
+  "  S() {}\n"
+  "  bool a_{false};\n"
+  "  bool b_{true};\n"
+  "};",
+  runCheckAndFormatOnCode(
+  "struct S { S() : a_(false), b_(true) {} bool a_; bool b_; };"));
+}
+
+TEST(UseDefaultMemberInitCheckTest, ExceptSpec) {
+  EXPECT_EQ(
+  "struct S {\n"
+  "  S() noexcept(true) {}\n"
+  "  bool a_{false};\n"
+  "  bool b_{true};\n"
+  "};",
+  runCheckAndFormatOnCode(
+  "struct S { S() noexcept(true) : a_(false), b_(true) {} bool a_; "
+  "bool b_; };"));
+  EXPECT_EQ(
+  "#define NOEXCEPT_(X) noexcept(X)\n"
+  "struct S {\n"
+  "  S() NOEXCEPT_(true) {}\n"
+  "  bool a_{false};\n"
+  "  bool b_{true};\n"
+  "};",
+  runCheckAndFormatOnCode(
+  "#define NOEXCEPT_(X) noexcept(X)\n"
+  "struct S { S() NOEXCEPT_(true) : a_(false), b_(true) {} bool a_; "
+  "bool b_; };"));
+}
+
+TEST(UseDefaultMemberInitCheckTest, OnExisting) {
+  EXPECT_EQ("struct S {\n"
+"  S() {}\n"
+"  bool a_{false};\n"
+"  bool b_{true};\n"
+"};",
+runCheckAndFormatOnCode(
+"struct S { S() : a_(false), b_(true) {} bool a_{false}; bool "
+"b_{true}; };"));
+  EXPECT_EQ("struct S {\n"
+"  S() : a_(true) {}\n"
+"  bool a_{false};\n"
+"  bool b_{true};\n"
+"};",
+runCheckAndFormatOnCode(
+"struct S { S() : a_(true), b_(true) {} bool a_{false}; bool "
+"b_{true}; };"));
+  EXPECT_EQ("struct S {\n"
+"  S() : b_(false) {}\n"
+"  bool a_{false};\n"
+"  bool b_{true};\n"
+"};",
+runCheckAndFormatOnCode(
+"struct S { S() : a_(false), b_(false) {} bool a_{false}; bool "
+"b_{true}; };"));
+}
+
+} // namespace test
+} // namespace tidy
+} // namespace clang
Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -13,6 +13,7 @@
 #include "ClangTidy.h"
 #include "ClangTidyDiagnosticConsumer.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/Refactoring.h"
@@ -140,15 +141,55 @@
   }
   if (Errors)
 *Errors = Context.getErrors();
-  auto Result = tooling::applyAllReplacements(Code, Fixes);
+
+  if (Options.FormatStyle) {
+llvm::Expected Style = format::getStyle(
+*Options.FormatStyle, Filename.getSingleStringRef(), "LLVM");
+
+llvm::Expected CleannedReplacements =
+format::cleanupAroundReplacements(Code, Fixes, *Style);
+if (!CleannedReplacements) {
+  llvm::errs() << llvm::toString(CleannedReplacements.takeError()) << "\n";
+  return "";
+}
+if (llvm::Expected FormattedReplacements =
+format::formatReplacements(Code, *CleannedReplacements, *Style)) {
+  CleannedReplacements = std::move(FormattedReplacements);
+  if (!CleannedReplacements)
+return "";
+} else {
+  llvm::errs() << llvm::toString(FormattedReplacements.takeError())
+   << ". Skipping formatting.\n";
+  return "";
+}
+Fixes = *CleannedReplacements;
+  }
+
+  llvm::Expected Result =
+  tooling::applyAllReplacements(Code, Fixes);
   if (!Result) {
 // FIXME: propogate the error.
   

[PATCH] D43902: [clang-format] Don't detect C++11 attribute specifiers as ObjC

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:346
+  bool parseCpp11AttributeSpecifier(FormatToken *Tok) {
+if (!Style.isCpp()) return false;
+if (!Tok || !Tok->startsSequence(tok::l_square, tok::l_square))

C can use this syntax as well with `-fdouble-square-bracket-attributes`, which 
would be good to also support.


Repository:
  rC Clang

https://reviews.llvm.org/D43902



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


[PATCH] D43905: [clang-format] Improve detection of ObjC for-in statements

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: krasimir, jolesiak.

Previously, clang-format would detect the following as an
Objective-C for-in statement:

  for (int x = in.value(); ...) {}

because the logic only decided a for-loop was definitely *not*
an Objective-C for-in loop after it saw a semicolon or a colon.

To fix this, I delayed the decision of whether this was a for-in
statement until after we found the matching right-paren, at which
point we know if we've seen a semicolon or not.

Depends On https://reviews.llvm.org/D43904

Test Plan: New tests added. Ran tests with:

  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D43905

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11999,6 +11999,31 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithForIn) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "for (Foo *x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in bar) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:blech]) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "for (Foo *x in [bar baz:blech, 1, 2, 3, 0]) 
{}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:^{[uh oh];}]) 
{}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "Foo *x; for (x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "Foo *x; for (x in y) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage(
+  "foo.h",
+  "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -285,6 +285,16 @@
 else
   Left->PackingKind = PPK_OnePerLine;
 
+if (MightBeObjCForRangeLoop) {
+  FormatToken *ForInToken = Left;
+  while (ForInToken && ForInToken != CurrentToken) {
+if (ForInToken->is(Keywords.kw_in)) {
+  ForInToken->Type = TT_ObjCForIn;
+  break;
+}
+ForInToken = ForInToken->Next;
+  }
+}
 next();
 return true;
   }
@@ -303,8 +313,6 @@
 Contexts.back().IsExpression = false;
   if (CurrentToken->isOneOf(tok::semi, tok::colon))
 MightBeObjCForRangeLoop = false;
-  if (MightBeObjCForRangeLoop && CurrentToken->is(Keywords.kw_in))
-CurrentToken->Type = TT_ObjCForIn;
   // When we discover a 'new', we set CanBeExpression to 'false' in order 
to
   // parse the type correctly. Reset that after a comma.
   if (CurrentToken->is(tok::comma))


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11999,6 +11999,31 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithForIn) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "for (Foo *x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in bar) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:blech]) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "for (Foo *x in [bar baz:blech, 1, 2, 3, 0]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:^{[uh oh];}]) {}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "Foo *x; for (x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "Foo *x; for (x in y) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage(
+  "foo.h",
+  "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ 

[PATCH] D43906: [clang-format] Improve detection of Objective-C block types

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: krasimir, jolesiak.
Herald added a subscriber: cfe-commits.

Previously, clang-format would detect the following as an
Objective-C block type:

  FOO(^);

when it actually must be a C or C++ macro dealing with an XOR
statement or an XOR operator overload.

According to the Clang Block Language Spec:

https://clang.llvm.org/docs/BlockLanguageSpec.html

block types are of the form:

  int (^)(char, float)

and block variables of block type are of the form:

  void (^blockReturningVoidWithVoidArgument)(void);
  int (^blockReturningIntWithIntAndCharArguments)(int, char);
  void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int);

This tightens up the detection so we don't unnecessarily detect
C macros which pass in the XOR operator.

Depends On https://reviews.llvm.org/D43904

Test Plan: New tests added. Ran tests with:

  make -j12 FormatTests &&
  ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D43906

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12024,6 +12024,16 @@
   "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithCaret) {
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "FOO(^);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo[10])(char, float);"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -142,8 +142,20 @@
 
 bool StartsObjCMethodExpr = false;
 if (CurrentToken->is(tok::caret)) {
-  // (^ can start a block type.
-  Left->Type = TT_ObjCBlockLParen;
+  const FormatToken *Next = CurrentToken->getNextNonComment();
+  if (Next &&
+  // int (^)(char, float)
+  (Next->startsSequence(tok::r_paren, tok::l_paren) ||
+   // int (^blockReturningIntWithCharAndFloatArguments)(char, float)
+   Next->startsSequence(tok::identifier, tok::r_paren, tok::l_paren) ||
+   // int
+   // 
(^arrayOfTenBlocksReturningIntWithCharAndFloatArguments[10])(char,
+   // float)
+   Next->startsSequence(tok::identifier, tok::l_square,
+tok::numeric_constant, tok::r_square,
+tok::r_paren, tok::l_paren))) {
+Left->Type = TT_ObjCBlockLParen;
+  }
 } else if (FormatToken *MaybeSel = Left->Previous) {
   // @selector( starts a selector.
   if (MaybeSel->isObjCAtKeyword(tok::objc_selector) && MaybeSel->Previous 
&&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12024,6 +12024,16 @@
   "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithCaret) {
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "FOO(^);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo)(char, float);"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "int(^foo[10])(char, float);"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -142,8 +142,20 @@
 
 bool StartsObjCMethodExpr = false;
 if (CurrentToken->is(tok::caret)) {
-  // (^ can start a block type.
-  Left->Type = TT_ObjCBlockLParen;
+  const FormatToken *Next = CurrentToken->getNextNonComment();
+  if (Next &&
+  // int (^)(char, float)
+  (Next->startsSequence(tok::r_paren, tok::l_paren) ||
+   // int (^blockReturningIntWithCharAndFloatArguments)(char, float)
+   Next->startsSequence(tok::identifier, tok::r_paren, tok::l_paren) ||
+   // int
+   // (^arrayOfTenBlocksReturningIntWithCharAndFloatArguments[10])(char,
+   // float)
+   Next->startsSequence(tok::identifier, tok::l_square,
+tok::numeric_constant, tok::r_square,
+tok::r_paren, tok::l_paren))) {
+Left->Type = TT_ObjCBlockLParen;
+  }

[PATCH] D43905: [clang-format] Improve detection of ObjC for-in statements

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton abandoned this revision.
benhamilton added a comment.

Whoops, sent out twice.


Repository:
  rC Clang

https://reviews.llvm.org/D43905



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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5639
+  "local variable %0 will be copied despite being %select{returned|thrown}1 by 
name">,
+  InGroup, DefaultIgnore;
+def note_add_std_move : Note<

I would like some guidance on whether it would be appropriate to turn this 
warning on as part of `-Wmove`.



Comment at: lib/Sema/SemaStmt.cpp:3083
+Diag(Value->getExprLoc(), diag::warn_return_std_move_in_cxx11)
+<< Value->getSourceRange()
+<< NRVOCandidate->getDeclName() << ResultType << QT;

This source range does the right thing; thanks @rtrieu!


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


[PATCH] D43904: [clang-format] Improve detection of ObjC for-in statements

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: krasimir, jolesiak.
Herald added a subscriber: cfe-commits.

Previously, clang-format would detect the following as an
Objective-C for-in statement:

  for (int x = in.value(); ...) {}

because the logic only decided a for-loop was definitely *not*
an Objective-C for-in loop after it saw a semicolon or a colon.

To fix this, I delayed the decision of whether this was a for-in
statement until after we found the matching right-paren, at which
point we know if we've seen a semicolon or not.

Test Plan: New tests added. Ran tests with:

  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D43904

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11999,6 +11999,31 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithForIn) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "for (Foo *x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in bar) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:blech]) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "for (Foo *x in [bar baz:blech, 1, 2, 3, 0]) 
{}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:^{[uh oh];}]) 
{}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "Foo *x; for (x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "Foo *x; for (x in y) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage(
+  "foo.h",
+  "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -285,6 +285,16 @@
 else
   Left->PackingKind = PPK_OnePerLine;
 
+if (MightBeObjCForRangeLoop) {
+  FormatToken *ForInToken = Left;
+  while (ForInToken && ForInToken != CurrentToken) {
+if (ForInToken->is(Keywords.kw_in)) {
+  ForInToken->Type = TT_ObjCForIn;
+  break;
+}
+ForInToken = ForInToken->Next;
+  }
+}
 next();
 return true;
   }
@@ -303,8 +313,6 @@
 Contexts.back().IsExpression = false;
   if (CurrentToken->isOneOf(tok::semi, tok::colon))
 MightBeObjCForRangeLoop = false;
-  if (MightBeObjCForRangeLoop && CurrentToken->is(Keywords.kw_in))
-CurrentToken->Type = TT_ObjCForIn;
   // When we discover a 'new', we set CanBeExpression to 'false' in order 
to
   // parse the type correctly. Reset that after a comma.
   if (CurrentToken->is(tok::comma))


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11999,6 +11999,31 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithForIn) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "for (Foo *x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in bar) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:blech]) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "for (Foo *x in [bar baz:blech, 1, 2, 3, 0]) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "for (Foo *x in [bar baz:^{[uh oh];}]) {}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "Foo *x; for (x = 0; x != in; x++) {}"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "Foo *x; for (x in y) {}"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage(
+  "foo.h",
+  "for (const Foo& baz = in.value(); !baz.at_end(); ++baz) {}"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ 

[PATCH] D43902: [clang-format] Don't detect C++11 attribute specifiers as ObjC

2018-02-28 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: krasimir, jolesiak.
Herald added a subscriber: cfe-commits.

Previously, clang-format would detect C++11 and C++17 attribute
specifiers like the following as Objective-C method invocations:

  [[noreturn]];
  [[clang::fallthrough]];
  [[noreturn, deprecated("so sorry")]];
  [[using gsl: suppress("type")]];

To fix this, I ported part of the logic from
tools/clang/lib/Parse/ParseTentative.cpp into TokenAnnotator.cpp so we
can explicitly parse and identify C++11 attribute specifiers.

This allows the guessLanguage() and getStyle() APIs to correctly
guess files containing the C++11 attribute specifiers as C++,
not Objective-C.

Test Plan: New tests added. Ran tests with:

  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D43902

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11969,6 +11969,36 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[noreturn]];"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "array[[calculator getIndex]];"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "[[noreturn, deprecated(\"so sorry\")]];"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "[[noreturn, deprecated(\"gone, sorry\")]];"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "[[noreturn foo] bar];"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "[[clang::fallthrough]];"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "[[clang:fallthrough] foo];"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "[[gsl::suppress(\"type\")]];"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "[[using clang: fallthrough]];"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "[[abusing clang:fallthrough] bar];"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "[[using gsl: suppress(\"type\")]];"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h",
+"[[clang::callable_when(\"unconsumed\", \"unknown\")]]"));
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", "[[foo::bar, ...]]"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -320,13 +320,65 @@
 return false;
   }
 
+  const FormatToken *parseCpp11Attribute(const FormatToken *Tok,
+ bool NamespaceAllowed) {
+if (!Tok || !Tok->isOneOf(tok::identifier, tok::ellipsis)) return Tok;
+Tok = Tok->Next;
+if (!Tok) return nullptr;
+if (NamespaceAllowed &&
+Tok->startsSequence(tok::coloncolon, tok::identifier)) {
+  Tok = Tok->Next->Next;
+}
+if (!Tok) return nullptr;
+if (Tok->is(tok::l_paren)) {
+  const FormatToken *ParamToken = Tok->Next;
+  while (ParamToken && ParamToken->isNot(tok::r_paren))
+ParamToken = ParamToken->Next;
+  if (!ParamToken || ParamToken->isNot(tok::r_paren)) return nullptr;
+  Tok = ParamToken->Next;
+}
+return Tok;
+  }
+
+  // Look for [[ ... ]] which is a valid C++11 attribute specifier but
+  // never a valid Objective-C or Objective-C++ method invocation.
+  bool parseCpp11AttributeSpecifier(FormatToken *Tok) {
+if (!Style.isCpp()) return false;
+if (!Tok || !Tok->startsSequence(tok::l_square, tok::l_square))
+  return false;
+const FormatToken *AttributeToken = Tok->Next->Next;
+if (!AttributeToken) return false;
+// C++17 '[[using namespace: foo, bar(baz, blech)]]'
+if (AttributeToken->startsSequence(tok::kw_using, tok::identifier,
+   tok::colon)) {
+  AttributeToken = AttributeToken->Next->Next->Next;
+  while (AttributeToken) {
+AttributeToken =
+parseCpp11Attribute(AttributeToken, /*NamespaceAllowed=*/false);
+if (!AttributeToken || AttributeToken->isNot(tok::comma)) break;
+AttributeToken = AttributeToken->Next;
+  }
+} else {
+  // C++11 '[[namespace::foo, namespace::bar(baz, blech)]]'
+  while (AttributeToken) {
+AttributeToken =
+parseCpp11Attribute(AttributeToken, /*NamespaceAllowed=*/true);
+if (!AttributeToken || AttributeToken->isNot(tok::comma)) break;
+

[PATCH] D43734: [RecordLayout] Don't align to non-power-of-2 sizes when using -mms-bitfields

2018-02-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp:1758
+ Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
+"Non PowerOf2 size outside of GNU mode");
+if (TypeSize > FieldAlign &&

mstorsjo wrote:
> efriedma wrote:
> > This assertion seems weird.  `sizeof(long double)` is 12 for other targets, 
> > including x86-32 Linux.
> Perhaps it'd make more sense to flip it around, `assert(isPowerOf2() || 
> !Triple.isWindowsMSVCEnvironment())`?
Yes, that makes sense.


Repository:
  rL LLVM

https://reviews.llvm.org/D43734



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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 136383.
Quuxplusone added a comment.

Rename some functions and parameters. Rebase onto 
https://reviews.llvm.org/D43898.


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &(T &);
+} // namespace foo
+} // namespace std
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+TrivialInstrument i;
+ConstructFromTrivialBase(const TrivialBase& b): i(b.i) {}
+ConstructFromTrivialBase(TrivialBase&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromTrivialDerived {
+TrivialInstrument i;
+ConstructFromTrivialDerived(const TrivialDerived& d): i(d.i) {}
+ConstructFromTrivialDerived(TrivialDerived&& d): i(std::move(d.i)) {}
+};
+
+Derived test1() {
+Derived d1;
+return d1;  // ok
+}
+Base test2() {
+Derived d2;
+return d2;  // e1
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
+}
+ConstructFromDerived test3() {
+Derived d3;
+return d3;  // e2-cxx11
+// expected-warning@-1{{would have been copied despite being returned by name}}
+// expected-note@-2{{to avoid copying on older compilers}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+}
+ConstructFromBase test4() {
+Derived d4;
+return d4;  // e3
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
+}
+ConvertFromDerived test5() {
+Derived d5;
+return d5;  // e4
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
+}
+ConvertFromBase test6() {
+Derived d6;
+return d6;  // e5
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
+}
+
+// These test cases should not produce the warning.
+Derived ok1() { Derived d; return d; }
+Base ok2() { Derived d; return static_cast(d); }
+ConstructFromDerived ok3() { Derived d; return static_cast(d); }
+ConstructFromBase ok4() { Derived d; return static_cast(d); }

[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:2937
 
+static void AttemptMoveInitialization(Sema& S,
+  const InitializedEntity ,

rtrieu wrote:
> I have a few concerns about this function.  The code isn't a straight move 
> from the old location to this one, so it is hard to follow along the changes, 
> especially the change to the complex if conditional.  The function should be 
> commented, especially to behavior difference for setting IsFake.
> 
> It looks like when IsFake is set, then the result is discarded and not used, 
> but it is still possible on success for AsRvalue to be copied to the heap.  
> This is wasteful when it is never used again.
> 
> Another issue is the Value in the original code is used again towards the end 
> of the function on line #3013.  In the old code, Value can be updated while 
> in the new code, it does.
> 
> It may be better to split this change in two, the first adding this function 
> and the CopyElisionSemanticsKind enum and the second adding the diagnostic 
> itself.
Hi @rtrieu, and thanks!

I have split out the first half of the patch into a new revision D43898, and 
updated this one with the full patch (both halves together). Is there an easy 
way for me to make "just the second half" reviewable on its own, before the 
first half has been merged to master?

> It looks like when IsFake is set, then the result is discarded and not used, 
> but it is still possible on success for AsRvalue to be copied to the heap. 
> This is wasteful when it is never used again.

I believe you are correct. But I'm not sure if it's safe to use `AsRvalue` as 
input to `Res` (which *is* used outside this function) if it's not moved like 
this; I don't know much about the internals here. You or anyone have a 
suggestion for how to fix that issue?

> In the old code, Value can be updated while in the new code, it does.

I can't parse this, sorry.

FYI, in the patch I'm about to upload, I have renamed `!IsFake` to 
`ConvertingConstructorsOnly`, which should be more pleasing to the eye. :)


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


[PATCH] D43734: [RecordLayout] Don't align to non-power-of-2 sizes when using -mms-bitfields

2018-02-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp:1758
+ Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
+"Non PowerOf2 size outside of GNU mode");
+if (TypeSize > FieldAlign &&

efriedma wrote:
> This assertion seems weird.  `sizeof(long double)` is 12 for other targets, 
> including x86-32 Linux.
Perhaps it'd make more sense to flip it around, `assert(isPowerOf2() || 
!Triple.isWindowsMSVCEnvironment())`?


Repository:
  rL LLVM

https://reviews.llvm.org/D43734



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


[PATCH] D43734: [RecordLayout] Don't align to non-power-of-2 sizes when using -mms-bitfields

2018-02-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp:1758
+ Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
+"Non PowerOf2 size outside of GNU mode");
+if (TypeSize > FieldAlign &&

This assertion seems weird.  `sizeof(long double)` is 12 for other targets, 
including x86-32 Linux.


Repository:
  rL LLVM

https://reviews.llvm.org/D43734



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


[PATCH] D43898: Preliminary refactoring in service of -Wreturn-std-move. NFC.

2018-02-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 136380.
Quuxplusone added a comment.

Add a block comment for function `TryMoveInitialization`.


Repository:
  rC Clang

https://reviews.llvm.org/D43898

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp

Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -741,7 +741,7 @@
 
   if (D->isNRVOVariable()) {
 QualType ReturnType = cast(DC)->getReturnType();
-if (SemaRef.isCopyElisionCandidate(ReturnType, Var, false))
+if (SemaRef.isCopyElisionCandidate(ReturnType, Var, Sema::CES_Strict))
   Var->setNRVOVariable(true);
   }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2862,16 +2862,16 @@
 /// \param E The expression being returned from the function or block, or
 /// being thrown.
 ///
-/// \param AllowParamOrMoveConstructible Whether we allow function parameters or
+/// \param CESK Whether we allow function parameters or
 /// id-expressions that could be moved out of the function to be considered NRVO
 /// candidates. C++ prohibits these for NRVO itself, but we re-use this logic to
 /// determine whether we should try to move as part of a return or throw (which
 /// does allow function parameters).
 ///
 /// \returns The NRVO candidate variable, if the return statement may use the
 /// NRVO, or NULL if there is no such candidate.
 VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, Expr *E,
-   bool AllowParamOrMoveConstructible) {
+   CopyElisionSemanticsKind CESK) {
   if (!getLangOpts().CPlusPlus)
 return nullptr;
 
@@ -2884,29 +2884,29 @@
   if (!VD)
 return nullptr;
 
-  if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
+  if (isCopyElisionCandidate(ReturnType, VD, CESK))
 return VD;
   return nullptr;
 }
 
 bool Sema::isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
-  bool AllowParamOrMoveConstructible) {
+  CopyElisionSemanticsKind CESK) {
   QualType VDType = VD->getType();
   // - in a return statement in a function with ...
   // ... a class return type ...
   if (!ReturnType.isNull() && !ReturnType->isDependentType()) {
 if (!ReturnType->isRecordType())
   return false;
 // ... the same cv-unqualified type as the function return type ...
 // When considering moving this expression out, allow dissimilar types.
-if (!AllowParamOrMoveConstructible && !VDType->isDependentType() &&
+if (!(CESK & CES_AllowDifferentTypes) && !VDType->isDependentType() &&
 !Context.hasSameUnqualifiedType(ReturnType, VDType))
   return false;
   }
 
   // ...object (other than a function or catch-clause parameter)...
   if (VD->getKind() != Decl::Var &&
-  !(AllowParamOrMoveConstructible && VD->getKind() == Decl::ParmVar))
+  !((CESK & CES_AllowParameters) && VD->getKind() == Decl::ParmVar))
 return false;
   if (VD->isExceptionVariable()) return false;
 
@@ -2918,7 +2918,7 @@
   // variable will no longer be used.
   if (VD->hasAttr()) return false;
 
-  if (AllowParamOrMoveConstructible)
+  if (CESK & CES_AllowDifferentTypes)
 return true;
 
   // ...non-volatile...
@@ -2933,6 +2933,70 @@
   return true;
 }
 
+/// \brief Try to perform the initialization of a potentially-movable value,
+/// which is the operand to a return or throw statement.
+///
+/// This routine implements C++14 [class.copy]p32, which attempts to treat
+/// returned lvalues as rvalues in certain cases (to prefer move construction),
+/// then falls back to treating them as lvalues if that failed.
+///
+/// \param Res We will fill this in if move-initialization was possible.
+/// If move-initialization is not possible, such that we must fall back to
+/// treating the operand as an lvalue, we will leave Res in its original
+/// invalid state.
+static void TryMoveInitialization(Sema& S,
+  const InitializedEntity ,
+  const VarDecl *NRVOCandidate,
+  QualType ResultType,
+  Expr *Value,
+  ExprResult )
+{
+  ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
+CK_NoOp, Value, VK_XValue);
+
+  Expr *InitExpr = 
+
+  InitializationKind Kind = InitializationKind::CreateCopy(
+  Value->getLocStart(), Value->getLocStart());
+
+  InitializationSequence Seq(S, Entity, Kind, InitExpr);
+  if (Seq) {
+for (const InitializationSequence::Step  : Seq.steps()) {
+  if (!(Step.Kind == 

[PATCH] D43898: Preliminary refactoring in service of -Wreturn-std-move. NFC.

2018-02-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added a reviewer: rtrieu.
Herald added a subscriber: cfe-commits.

This patch is extracted from https://reviews.llvm.org/D43322, which adds a new 
diagnostic `-Wreturn-std-move`. This patch here is just the non-functional 
parts of that patch. It pulls `TryMoveInitialization` out into a separate 
function so that we can (in the next patch) try it twice — once with current 
C++ rules, and once with the rules as they would be if `return x` considered 
rvalue-ref-qualified conversion operators. This patch here does *not* add those 
new rules; it merely rearranges the existing code to make the next patch less 
bulky.


Repository:
  rC Clang

https://reviews.llvm.org/D43898

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp

Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -741,7 +741,7 @@
 
   if (D->isNRVOVariable()) {
 QualType ReturnType = cast(DC)->getReturnType();
-if (SemaRef.isCopyElisionCandidate(ReturnType, Var, false))
+if (SemaRef.isCopyElisionCandidate(ReturnType, Var, Sema::CES_Strict))
   Var->setNRVOVariable(true);
   }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2862,16 +2862,16 @@
 /// \param E The expression being returned from the function or block, or
 /// being thrown.
 ///
-/// \param AllowParamOrMoveConstructible Whether we allow function parameters or
+/// \param CESK Whether we allow function parameters or
 /// id-expressions that could be moved out of the function to be considered NRVO
 /// candidates. C++ prohibits these for NRVO itself, but we re-use this logic to
 /// determine whether we should try to move as part of a return or throw (which
 /// does allow function parameters).
 ///
 /// \returns The NRVO candidate variable, if the return statement may use the
 /// NRVO, or NULL if there is no such candidate.
 VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, Expr *E,
-   bool AllowParamOrMoveConstructible) {
+   CopyElisionSemanticsKind CESK) {
   if (!getLangOpts().CPlusPlus)
 return nullptr;
 
@@ -2884,29 +2884,29 @@
   if (!VD)
 return nullptr;
 
-  if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
+  if (isCopyElisionCandidate(ReturnType, VD, CESK))
 return VD;
   return nullptr;
 }
 
 bool Sema::isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
-  bool AllowParamOrMoveConstructible) {
+  CopyElisionSemanticsKind CESK) {
   QualType VDType = VD->getType();
   // - in a return statement in a function with ...
   // ... a class return type ...
   if (!ReturnType.isNull() && !ReturnType->isDependentType()) {
 if (!ReturnType->isRecordType())
   return false;
 // ... the same cv-unqualified type as the function return type ...
 // When considering moving this expression out, allow dissimilar types.
-if (!AllowParamOrMoveConstructible && !VDType->isDependentType() &&
+if (!(CESK & CES_AllowDifferentTypes) && !VDType->isDependentType() &&
 !Context.hasSameUnqualifiedType(ReturnType, VDType))
   return false;
   }
 
   // ...object (other than a function or catch-clause parameter)...
   if (VD->getKind() != Decl::Var &&
-  !(AllowParamOrMoveConstructible && VD->getKind() == Decl::ParmVar))
+  !((CESK & CES_AllowParameters) && VD->getKind() == Decl::ParmVar))
 return false;
   if (VD->isExceptionVariable()) return false;
 
@@ -2918,7 +2918,7 @@
   // variable will no longer be used.
   if (VD->hasAttr()) return false;
 
-  if (AllowParamOrMoveConstructible)
+  if (CESK & CES_AllowDifferentTypes)
 return true;
 
   // ...non-volatile...
@@ -2933,6 +2933,58 @@
   return true;
 }
 
+static void TryMoveInitialization(Sema& S,
+  const InitializedEntity ,
+  const VarDecl *NRVOCandidate,
+  QualType ResultType,
+  Expr *Value,
+  ExprResult )
+{
+  ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(),
+CK_NoOp, Value, VK_XValue);
+
+  Expr *InitExpr = 
+
+  InitializationKind Kind = InitializationKind::CreateCopy(
+  Value->getLocStart(), Value->getLocStart());
+
+  InitializationSequence Seq(S, Entity, Kind, InitExpr);
+  if (Seq) {
+for (const InitializationSequence::Step  : Seq.steps()) {
+  if (!(Step.Kind == InitializationSequence::SK_ConstructorInitialization ||
+Step.Kind == 

[PATCH] D42893: [libclang] Add clang_File_tryGetRealPathName

2018-02-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D42893



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


r326370 - Attempt to fix cl-include.c on Windows.

2018-02-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 28 12:58:06 2018
New Revision: 326370

URL: http://llvm.org/viewvc/llvm-project?rev=326370=rev
Log:
Attempt to fix cl-include.c on Windows.

Modified:
cfe/trunk/test/Driver/cl-include.c

Modified: cfe/trunk/test/Driver/cl-include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-include.c?rev=326370=326369=326370=diff
==
--- cfe/trunk/test/Driver/cl-include.c (original)
+++ cfe/trunk/test/Driver/cl-include.c Wed Feb 28 12:58:06 2018
@@ -14,12 +14,12 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc 
-### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
 // NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
-// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*lib.*clang.*include}}"
 // NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
 
 // /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
 // RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- 
%s 2>&1 | FileCheck %s --check-prefix=SLASHX
 // SLASHX-NOT: "argument unused{{.*}}-imsvc"
 // SLASHX-NOT: "-internal-isystem" "/my/system/inc"
-// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "{{.*lib.*clang.*include}}"
 // SLASHX: "-internal-isystem" "/my/other/inc"


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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This is limited to escaping blocks because disabling tail-call optimizations 
for all blocks might impact performance. The user is claiming that non-escaping 
blocks are often used in areas that are performance-sensitive (for example, 
dispatch_sync() and -[NSArray enumerateObjectsUsingBlock:] in a tight loop), so 
disabling tail-call optimization indiscriminately can cause performance 
degradation (and clients might decide not to use the command line option 
because of that).


https://reviews.llvm.org/D43841



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


[PATCH] D43852: [OpenMP] Extend NVPTX SPMD implementation of combined constructs

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326368: [OpenMP] Extend NVPTX SPMD implementation of 
combined constructs (authored by cbertol, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43852?vs=136214=136369#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43852

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_debug_codegen.cpp

Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -197,6 +197,7 @@
 LANGOPT(OpenMPSimd, 1, 0, "Use SIMD only OpenMP support.")
 LANGOPT(OpenMPUseTLS  , 1, 0, "Use TLS for threadprivates or runtime calls")
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target device")
+LANGOPT(OpenMPCUDAMode, 1, 0, "Generate code for OpenMP pragmas in SIMT/SPMD mode")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1424,6 +1424,8 @@
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
 def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, Flags<[CC1Option, NoArgumentUnused]>;
+def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group, Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;
Index: cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
+++ cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
@@ -1,9 +1,9 @@
 // Test target codegen - host bc file has to be created first.
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 

r326368 - [OpenMP] Extend NVPTX SPMD implementation of combined constructs

2018-02-28 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Wed Feb 28 12:48:35 2018
New Revision: 326368

URL: http://llvm.org/viewvc/llvm-project?rev=326368=rev
Log:
[OpenMP] Extend NVPTX SPMD implementation of combined constructs

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

This patch extends the SPMD implementation to all target constructs and guards 
this implementation under a new flag.



Added:
cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_debug_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=326368=326367=326368=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Feb 28 12:48:35 2018
@@ -197,6 +197,7 @@ LANGOPT(OpenMP, 32, 0, "Open
 LANGOPT(OpenMPSimd, 1, 0, "Use SIMD only OpenMP support.")
 LANGOPT(OpenMPUseTLS  , 1, 0, "Use TLS for threadprivates or runtime 
calls")
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target 
device")
+LANGOPT(OpenMPCUDAMode, 1, 0, "Generate code for OpenMP pragmas in 
SIMT/SPMD mode")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326368=326367=326368=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 28 12:48:35 2018
@@ -1424,6 +1424,8 @@ def fnoopenmp_relocatable_target : Flag<
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
 def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, 
Group, Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=326368=326367=326368=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Feb 28 12:48:35 2018
@@ -271,21 +271,10 @@ bool CGOpenMPRuntimeNVPTX::isInSpmdExecu
 }
 
 static CGOpenMPRuntimeNVPTX::ExecutionMode
-getExecutionModeForDirective(CodeGenModule ,
- const OMPExecutableDirective ) {
-  OpenMPDirectiveKind DirectiveKind = D.getDirectiveKind();
-  switch (DirectiveKind) {
-  case OMPD_target:
-  case OMPD_target_teams:
-return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
-  case OMPD_target_parallel:
-  case OMPD_target_parallel_for:
-  case OMPD_target_parallel_for_simd:
-return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
-  default:
-llvm_unreachable("Unsupported directive on NVPTX device.");
-  }
-  llvm_unreachable("Unsupported directive on NVPTX device.");
+getExecutionMode(CodeGenModule ) {
+  return CGM.getLangOpts().OpenMPCUDAMode
+ ? CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd
+ : CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
 }
 
 void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective ,
@@ -819,8 +808,7 @@ void CGOpenMPRuntimeNVPTX::emitTargetOut
 
   assert(!ParentName.empty() && "Invalid target region parent name!");
 
-  CGOpenMPRuntimeNVPTX::ExecutionMode Mode =
-  

r326366 - [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

2018-02-28 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Feb 28 12:31:55 2018
New Revision: 326366

URL: http://llvm.org/viewvc/llvm-project?rev=326366=rev
Log:
[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-toolchain-elf.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326366=326365=326366=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 28 12:31:55 2018
@@ -2496,6 +2496,8 @@ def mno_hexagon_hvx_double
 : Flag<[ "-" ], "mno-hvx-double">,
   Group,
   HelpText<"Disable Hexagon Double Vector eXtensions">;
+def ffixed_r19: Flag<["-"], "ffixed-r19">,
+  HelpText<"Reserve the r19 register (Hexagon only)">;
 
 
 // X86 feature flags

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=326366=326365=326366=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Feb 28 12:31:55 2018
@@ -521,11 +521,15 @@ unsigned HexagonToolChain::getOptimizati
 void HexagonToolChain::addClangTargetOptions(const ArgList ,
  ArgStringList ,
  Action::OffloadKind) const {
-  if (DriverArgs.hasArg(options::OPT_ffp_contract))
-return;
-  unsigned OptLevel = getOptimizationLevel(DriverArgs);
-  if (OptLevel >= 3)
-CC1Args.push_back("-ffp-contract=fast");
+  if (!DriverArgs.hasArg(options::OPT_ffp_contract)) {
+unsigned OptLevel = getOptimizationLevel(DriverArgs);
+if (OptLevel >= 3)
+  CC1Args.push_back("-ffp-contract=fast");
+  }
+  if (DriverArgs.hasArg(options::OPT_ffixed_r19)) {
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+reserved-r19");
+  }
 }
 
 void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList ,

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=326366=326365=326366=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Wed Feb 28 12:31:55 2018
@@ -504,12 +504,22 @@
 // CHECK060-NEXT: hexagon-link
 
 // 
-
+// ffixed-r19
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf -ffixed-r19 %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK070 %s
+// CHECK070: "-target-feature" "+reserved-r19"
+// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK071 %s
+// CHECK071-NOT: "+reserved-r19"
+
+// 
-
 // Misc Defaults
 // 
-
 // RUN: %clang -### -target hexagon-unknown-elf \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv60 \
 // RUN:   %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK070 %s
-// CHECK070:  "-cc1"
-// CHECK070:  "-Wreturn-type"
+// RUN:   | FileCheck -check-prefix=CHECK080 %s
+// CHECK080:  "-cc1"
+// CHECK080:  "-Wreturn-type"


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


[clang-tools-extra] r326365 - [clangd] Try to fix failures on clang-x64-ninja-win7 build bot.

2018-02-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Feb 28 12:31:00 2018
New Revision: 326365

URL: http://llvm.org/viewvc/llvm-project?rev=326365=rev
Log:
[clangd] Try to fix failures on clang-x64-ninja-win7 build bot.

Modified:
clang-tools-extra/trunk/test/clangd/crash-non-added-files.test
clang-tools-extra/trunk/test/clangd/hover.test
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test
clang-tools-extra/trunk/test/clangd/insert-include.test

Modified: clang-tools-extra/trunk/test/clangd/crash-non-added-files.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/crash-non-added-files.test?rev=326365=326364=326365=diff
==
--- clang-tools-extra/trunk/test/clangd/crash-non-added-files.test (original)
+++ clang-tools-extra/trunk/test/clangd/crash-non-added-files.test Wed Feb 28 
12:31:00 2018
@@ -1,28 +1,28 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start":
 {"line": 0, "character": 32}, "end": {"line": 0, "character": 
37}},"severity":2,"message":"using the result of an assignment as a condition 
without parentheses"},{"range":{"start": {"line": 0, "character": 34}, "end": 
{"line": 0, "character": 35}},"severity":3,"message":"place parentheses around 
the assignment to silence this warning"},{"range":{"start": {"line": 0, 
"character": 34}, "end": {"line": 0, "character": 
35}},"severity":3,"message":"use '==' to turn this assignment into an equality 
comparison"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start":
 {"line": 0, "character": 32}, "end": {"line": 0, "character": 
37}},"severity":2,"message":"using the result of an assignment as a condition 
without parentheses"},{"range":{"start": {"line": 0, "character": 34}, "end": 
{"line": 0, "character": 35}},"severity":3,"message":"place parentheses around 
the assignment to silence this warning"},{"range":{"start": {"line": 0, 
"character": 34}, "end": {"line": 0, "character": 
35}},"severity":3,"message":"use '==' to turn this assignment into an equality 
comparison"}]}}}
 #  CHECK:  "error": {
 # CHECK-NEXT:"code": -32602
 # CHECK-NEXT:"message": "onCodeAction called for non-added file"
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "id": 2,
 ---
-{"jsonrpc":"2.0","id":3,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":1,"character":4},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
+{"jsonrpc":"2.0","id":3,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":1,"character":4},"end":{"line":1,"character":12}},"options":{"tabSize":4,"insertSpaces":true}}}
 #  CHECK:  "error": {
 # CHECK-NEXT:"code": -32602
 # CHECK-NEXT:"message": "onDocumentRangeFormatting called for non-added 
file"
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "id": 3,
 ---
-{"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
+{"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"test:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
 #  CHECK:  "error": {
 # CHECK-NEXT:"code": -32602
 # CHECK-NEXT:"message": "onDocumentFormatting called for non-added file"
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "id": 4,
 ---
-{"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"position":{"line":3,"character":1},"ch":"}","options":{"tabSize":4,"insertSpaces":true}}}
+{"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"position":{"line":3,"character":1},"ch":"}","options":{"tabSize":4,"insertSpaces":true}}}
 #  CHECK:  "error": {
 # CHECK-NEXT:"code": -32602
 # CHECK-NEXT:"message": "onDocumentOnTypeFormatting called for non-added 
file"

Modified: clang-tools-extra/trunk/test/clangd/hover.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/hover.test?rev=326365=326364=326365=diff
==
--- clang-tools-extra/trunk/test/clangd/hover.test (original)
+++ clang-tools-extra/trunk/test/clangd/hover.test Wed Feb 28 12:31:00 2018
@@ -1,9 

[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r326362


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


r326362 - CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Feb 28 12:16:12 2018
New Revision: 326362

URL: http://llvm.org/viewvc/llvm-project?rev=326362=rev
Log:
CodeGenObjCXX: handle inalloca appropriately for msgSend variant

objc_msgSend_stret takes a hidden parameter for the returned structure's
address for the construction.  When the function signature is rewritten
for the inalloca passing, the return type is no longer marked as
indirect but rather inalloca stret.  This enhances the test for the
indirect return to check for that case as well.  This fixes the
incorrect return classification for Windows x86.

Added:
cfe/trunk/test/CodeGenObjCXX/msabi-stret.mm
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=326362=326361=326362=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 28 12:16:12 2018
@@ -1479,7 +1479,8 @@ void ClangToLLVMArgMapping::construct(co
 /***/
 
 bool CodeGenModule::ReturnTypeUsesSRet(const CGFunctionInfo ) {
-  return FI.getReturnInfo().isIndirect();
+  const auto  = FI.getReturnInfo();
+  return RI.isIndirect() || (RI.isInAlloca() && RI.getInAllocaSRet());
 }
 
 bool CodeGenModule::ReturnSlotInterferesWithArgs(const CGFunctionInfo ) {

Added: cfe/trunk/test/CodeGenObjCXX/msabi-stret.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/msabi-stret.mm?rev=326362=auto
==
--- cfe/trunk/test/CodeGenObjCXX/msabi-stret.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/msabi-stret.mm Wed Feb 28 12:16:12 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-Os -S -emit-llvm -o - %s -mdisable-fp-elim | FileCheck %s
+
+struct S {
+  S() = default;
+  S(const S &) {}
+};
+
+@interface I
++ (S)m:(S)s;
+@end
+
+S f() {
+  return [I m:S()];
+}
+
+// CHECK: declare dllimport void @objc_msgSend_stret(i8*, i8*, ...)
+// CHECK-NOT: declare dllimport void @objc_msgSend(i8*, i8*, ...)
+


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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can you explain the rationale for limiting this to escaping blocks in more 
depth?  That seems like an extremely orthogonal limitation; the user might be 
thinking about a very specific block and not really considering this in general.


https://reviews.llvm.org/D43841



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, yeah, we can fix that later.  LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Yeah, this is still an indirect return.  I can see your point about the 
representation, nfortunately, I think that change is way out of scope for this. 
 That would be a pretty large and invasive change to wire that through.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


r326357 - [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 28 11:49:07 2018
New Revision: 326357

URL: http://llvm.org/viewvc/llvm-project?rev=326357=rev
Log:
[clang-cl] Implement /X

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs()
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed
by clang-cl), so just alias /X to that.

https://reviews.llvm.org/D43888

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-include.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=326357=326356=326357=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed Feb 28 11:49:07 2018
@@ -166,6 +166,9 @@ def _SLASH_wd4996 : CLFlag<"wd4996">, Al
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -388,7 +391,6 @@ def _SLASH_u : CLFlag<"u">;
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;

Modified: cfe/trunk/test/Driver/cl-include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-include.c?rev=326357=326356=326357=diff
==
--- cfe/trunk/test/Driver/cl-include.c (original)
+++ cfe/trunk/test/Driver/cl-include.c Wed Feb 28 11:49:07 2018
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s 
--check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | 
FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc 
-### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- 
%s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"


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


[PATCH] D43888: [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r326357, thanks!


https://reviews.llvm.org/D43888



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  In that case, this seems correct, although it seems to me that perhaps 
`inalloca` is not actually orthogonal to anything else.  In fact, it seems to 
me that maybe `inalloca` ought to just be a bit on the CGFunctionInfo and the 
individual ABIInfos should be left alone.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) 
{}

Why is this is a user-facing option?

If it needs to be a user-facing option, you also need to implement an override 
for `storeOptions()` as well.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:25
+const std::string MakeUniqueCheck::getDefaultMinimumLanguageVersion() const {
+  return Options.get("MakeSmartPtrFunction", "").empty() ? "c++14" : "c++11";
+}

What is this option? Why is this returning a string literal rather than 
something less error-prone like an enumeration?


https://reviews.llvm.org/D43766



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D43842#1022498, @rjmccall wrote:

> Ugh, I hate `inalloca` *so much*.
>
> It's still an indirect return, right?  It's just that the return-slot pointer 
> has to get stored to the `inalloca` allocation like any other argument?


Correct.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


r326332 - Test commit access: apply clang-format suggestion

2018-02-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Feb 28 08:57:33 2018
New Revision: 326332

URL: http://llvm.org/viewvc/llvm-project?rev=326332=rev
Log:
Test commit access: apply clang-format suggestion

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=326332=326331=326332=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Feb 28 08:57:33 2018
@@ -3823,8 +3823,8 @@ static void WriteDocumentation(RecordKee
 const Record  = *Doc.Documentation->getValueAsDef("Deprecated");
 const StringRef Replacement = Deprecated.getValueAsString("Replacement");
 if (!Replacement.empty())
-  OS << "  This attribute has been superseded by ``"
- << Replacement << "``.";
+  OS << "  This attribute has been superseded by ``" << Replacement
+ << "``.";
 OS << "\n\n";
   }
 


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for working on this!
Some more review notes.
Please look into adding a bit more tests.




Comment at: clang-doc/BitcodeWriter.cpp:179
+  assert(Inits.size() == RecordIdCount);
+  for (const auto  : Inits) RecordIdNameMap[Init.first] = Init.second;
+  assert(RecordIdNameMap.size() == RecordIdCount);

Since this is the only string we ever push to `Record`, can we add an assertion 
to make sure we always have enough room for it?
E.g.
```
for (const auto  : Inits) {
  RecordId RID = Init.first;
  RecordIdNameMap[RID] = Init.second;
  assert((1 + RecordIdNameMap[RID].size()) <= Record.size());
  // Since record was just created, it should not have any dynamic size.
  // Or move the small size into a variable and use it when declaring the 
Record and here.
}
```



Comment at: clang-doc/BitcodeWriter.cpp:230
+  prepRecordData(ID);
+  for (const char C : RecordIdNameMap[ID].Name) Record.push_back(C);
+  Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);

Sadly, i can **not** prove it via godbolt (can't add LLVM as library), but i'd 
//expect// streamlining this should at least not hurt, i.e. something like
```
Record.append(RecordIdNameMap[ID].Name.begin(), RecordIdNameMap[ID].Name.end());
```
?



Comment at: clang-doc/BitcodeWriter.cpp:196
+/// \brief Emits a record name to the BLOCKINFO block.
+void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {
+  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");

juliehockett wrote:
> lebedev.ri wrote:
> > Hmm, so i've been staring at this and 
> > http://llvm.org/doxygen/classllvm_1_1BitstreamWriter.html and i must say 
> > i'm not fond of this indirection.
> > 
> > What i don't understand is, in previous function, we don't store `BlockId`, 
> > why do we want to store `RecordId`?
> > Aren't they both unstable, and are implementation detail?
> > Do we want to store it (`RecordId`)? If yes, please explain it as a new 
> > comment in code.
> > 
> > If no, i guess this would work too?
> > ```
> > assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
> > Record.clear();
> > Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, 
> > RecordIdNameMap[ID].Name);
> > ```
> > And after that you can lower the default size of `SmallVector<> Record` 
> > down to, hm, `4`?
> I'm not entirely certain what you mean -- in `emitBlockId()`, we are storing 
> both the block id and the block name in separate records 
> (`BLOCKINFO_CODE_SETBID`, `BLOCKINFO_CODE_BLOCKNAME`, respectively). In 
> `emitRecordId()`, we're doing something slightly different, in that we emit 
> one record with both the record id and the record name (in record 
> `BLOCKINFO_CODE_SETRECORDNAME`). 
> 
> Replacing the copy loop here has the same issue as above, namely that there 
> isn't an easy way to convert between a `StringRef` and an array of `unsigned 
> char`.
Tried locally, and yes, we do need to output record id.

What we could **actually** do, is simply inline that `EmitRecord()`, first 
emitting the RID, and then the name.
```
template 
void EmitRecord(unsigned Code, int ID, const Container ) {
  // If we don't have an abbrev to use, emit this in its fully unabbreviated
  // form.
  auto Count = static_cast(makeArrayRef(Vals).size());
  EmitCode(bitc::UNABBREV_RECORD);
  EmitVBR(Code, 6);
  EmitVBR(Count + 1, 6); // Including ID
  EmitVBR64(ID, 6); // 'Prefix' with ID
  for (unsigned i = 0, e = Count; i != e; ++i)
EmitVBR64(Vals[i], 6);
}
```

But that will result in rather ugly code.
So given that the record names are quite short, and all the other strings we 
output directly, maybe leave it as it is for now, until it shows in profiles?




Comment at: clang-doc/BitcodeWriter.h:37
+  static constexpr unsigned SubblockIDSize = 4U;
+  static constexpr unsigned BoolSize = 1U;
+  static constexpr unsigned IntSize = 16U;

juliehockett wrote:
> lebedev.ri wrote:
> > Hmm, you build with asserts enabled, right?
> > I tried testing this, and three tests fail with
> > ```
> > clang-doc: /build/llvm/include/llvm/Bitcode/BitstreamWriter.h:122: void 
> > llvm::BitstreamWriter::Emit(uint32_t, unsigned int): Assertion `(Val & 
> > ~(~0U >> (32-NumBits))) == 0 && "High bits set!"' failed.
> > ```
> > ```
> > Failing Tests (3):
> > Clang Tools :: clang-doc/mapper-class-in-function.cpp
> > Clang Tools :: clang-doc/mapper-function.cpp
> > Clang Tools :: clang-doc/mapper-method.cpp
> > 
> >   Expected Passes: 6
> >   Unexpected Failures: 3
> > ```
> > At least one failure is because of `BoolSize`, so i'd suspect the assertion 
> > itself is wrong...
> I do, and I've definitely seen that one triggered before but it's been 
> because something was off in how the data was being outputted as I was 
> shifting things around. That said, I'm not seeing it in my local build with 
> this diff though -- I'll 

[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

That's right, most analyzer-oriented tests were added explicitly by me to 
`temporaries.cpp` and `lifetime-extension.cpp` in previous patches, so they 
didn't need to be changed in this patch. There didn't seem to be many FIXME 
tests specific to my work before i started doing it - it seems that i covered 
all of them by adding a `cfg-temporary-dtors=true` run-line in previous patches.


Repository:
  rC Clang

https://reviews.llvm.org/D43804



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


r326355 - Fix gcc -Wreturn-type warnings after r326307.

2018-02-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 28 11:28:47 2018
New Revision: 326355

URL: http://llvm.org/viewvc/llvm-project?rev=326355=rev
Log:
Fix gcc -Wreturn-type warnings after r326307.

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

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=326355=326354=326355=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Feb 28 11:28:47 2018
@@ -1595,6 +1595,7 @@ computeCopyInfoForBlockCapture(const Blo
 return std::make_pair(BlockCaptureEntityKind::None, BlockFieldFlags());
   }
   }
+  llvm_unreachable("after exhaustive PrimitiveCopyKind switch");
 }
 
 /// Find the set of block captures that need to be explicitly copied or 
destroy.
@@ -1797,6 +1798,7 @@ computeDestroyInfoForBlockCapture(const
 return std::make_pair(BlockCaptureEntityKind::None, BlockFieldFlags());
   }
   }
+  llvm_unreachable("after exhaustive DestructionKind switch");
 }
 
 /// Generate the destroy-helper function for a block closure object:


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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Currently there's no test demonstrating a different behavior from 
`cfg-temporary-dtors` being set to true?..


Repository:
  rC Clang

https://reviews.llvm.org/D43804



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Ugh, I hate `inalloca` *so much*.

It's still an indirect return, right?  It's just that the return-slot pointer 
has to get stored to the `inalloca` allocation like any other argument?


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/AST/Decl.h:1840
+  /// there is one).
+  ///
   bool hasBody(const FunctionDecl *) const;

Please remove trailing blank comment lines here and below.



Comment at: lib/Sema/SemaDecl.cpp:11986
+  !FD->isDefined(Definition)
+  && FD->getDeclContext()->isFileContext()) {
+// If this is a friend function defined in a class template, it does not

`&&` on the end of the previous line, please.

If the intent here is to detect non-member functions, using 
`!FD->isCXXClassMember()` or `!isa(FD)` would be clearer.



Comment at: lib/Sema/SemaDecl.cpp:11995-12006
+for (auto I : FD->redecls()) {
+  if (I != FD && !I->isInvalidDecl() &&
+  I->getFriendObjectKind() != Decl::FOK_None) {
+if (FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
+  if (Original->isThisDeclarationADefinition()) {
+Definition = I;
+break;

We should include a comment here explaining why we need to do this (that is, 
why this doesn't just fall out from the normal `isDefined` check). You can just 
quote C++ [temp.inst]p2:

> For the purpose of determining whether an instantiated redeclaration is valid 
> according to [basic.def.odr] and [class.mem], a declaration that corresponds 
> to a definition in the template is considered to be a definition.


https://reviews.llvm.org/D30170



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


[PATCH] D43840: [CFG] [analyzer] Fix a crash on finding construction context for implicit constructor conversion.

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Should there be a FIXME note saying that other casts should be supported?


Repository:
  rC Clang

https://reviews.llvm.org/D43840



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh, sorry, somehow I missed that it was abandoned.


https://reviews.llvm.org/D43839



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


[PATCH] D43888: [clang-cl] Implement /X

2018-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

Nicely tested too :-)


https://reviews.llvm.org/D43888



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


[clang-tools-extra] r326354 - [Documentation] Split Clang-tidy changes in Release Notes into sections: new checks, new aliases, renamed checks; sort all of them alphabetically. Enforce 80 characters l

2018-02-28 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Feb 28 11:15:49 2018
New Revision: 326354

URL: http://llvm.org/viewvc/llvm-project?rev=326354=rev
Log:
[Documentation] Split Clang-tidy changes in Release Notes into sections: new 
checks, new aliases, renamed checks; sort all of them alphabetically. Enforce 
80 characters line length limit. Highlight C++ keywords.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-trailing-return.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=326354=326353=326354=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Feb 28 11:15:49 2018
@@ -57,23 +57,11 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- The 'misc-misplaced-widening-cast' check was renamed to 
`bugprone-misplaced-widening-cast
-  
`_
-
-- The 'misc-lambda-function-name' check was renamed to 
`bugprone-lambda-function-name
-  
`_
-
-- The 'misc-macro-repeated-side-effects' check was renamed to 
`bugprone-macro-repeated-side-effects
-  
`_
-
-- The 'misc-forwarding-reference-overload' check was renamed to 
`bugprone-forwarding-reference-overload
-  
`_
-
-- The 'misc-incorrect-roundings' check was renamed to 
`bugprone-incorrect-roundings
-  
`_
+- New `bugprone-throw-keyword-missing
+  
`_
 check
 
-- The 'misc-string-compare' check was renamed to `readability-string-compare
-  
`_
+  Diagnoses when a temporary object that appears to be an exception is
+  constructed but not thrown.
 
 - New `cppcoreguidelines-avoid-goto
   
`_
 check
@@ -90,17 +78,23 @@ Improvements to clang-tidy
 - New `fuchsia-statically-constructed-objects
   
`_
 check
 
-  Warns if global, non-trivial objects with static storage are constructed, 
unless the 
-  object is statically initialized with a ``constexpr`` constructor or has no 
-  explicit constructor.
+  Warns if global, non-trivial objects with static storage are constructed,
+  unless the object is statically initialized with a ``constexpr`` constructor
+  or has no explicit constructor.
   
 - New `fuchsia-trailing-return
   
`_ 
check
 
   Functions that have trailing returns are disallowed, except for those 
-  using decltype specifiers and lambda with otherwise unutterable 
+  using ``decltype`` specifiers and lambda with otherwise unutterable 
   return types.
 
+- New `modernize-use-uncaught-exceptions
+  
`_
 check
+
+  Finds and replaces deprecated uses of ``std::uncaught_exception`` to
+  ``std::uncaught_exceptions``.
+
 - New `readability-simd-intrinsics
   
`_
 check
 
@@ -112,15 +106,23 @@ Improvements to clang-tidy
   `cppcoreguidelines-avoid-goto 
`_
   added.
 
-- New `bugprone-throw-keyword-missing
-  
`_
 check
+- The 'misc-forwarding-reference-overload' check was renamed to 
`bugprone-forwarding-reference-overload
+  
`_
 
-  Diagnoses when a temporary object that appears to be an exception is 
constructed but not thrown.
+- The 'misc-incorrect-roundings' check was renamed to 
`bugprone-incorrect-roundings
+  
`_
 
-- New `modernize-use-uncaught-exceptions
-  
`_
 check
+- The 'misc-lambda-function-name' check was renamed to 
`bugprone-lambda-function-name
+  

[PATCH] D43888: [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs() 
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed 
by clang-cl), so just alias /X to that.


https://reviews.llvm.org/D43888

Files:
  include/clang/Driver/CLCompatOptions.td
  test/Driver/cl-include.c


Index: test/Driver/cl-include.c
===
--- test/Driver/cl-include.c
+++ test/Driver/cl-include.c
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s 
--check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | 
FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc 
-### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- 
%s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -164,6 +164,9 @@
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -386,7 +389,6 @@
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;


Index: test/Driver/cl-include.c
===
--- test/Driver/cl-include.c
+++ test/Driver/cl-include.c
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -164,6 +164,9 @@
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -386,7 +389,6 @@
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:100
   void checkCall_strcat(const CallExpr *CE, const FunctionDecl *FD);
+  void checkDeprecatedOrUnsafeBufferHandling(const CallExpr *CE, const 
FunctionDecl *FD);
   void checkCall_rand(const CallExpr *CE, const FunctionDecl *FD);

80 chars



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:165
+.Case("strncat", ::checkDeprecatedOrUnsafeBufferHandling)
+.Case("memset", ::checkDeprecatedOrUnsafeBufferHandling)
 .Case("drand48", ::checkCall_rand)

That's a lot of duplicated `WalkAST::checkDeprecatedOrUnsafeBufferHandling`. 
Could that be simplified?



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:618
+  StringRef Name = FD->getIdentifier()->getName();
+  int ArgIndex = llvm::StringSwitch(Name)
+ .Case("sprintf", 1)

That's a lot of duplication of 1/0/-1.


And also 1/0/-1 are cryptic symbols, why not use an enum with a descriptive 
name?
Maybe use
`.Cases("sprintf", "vsprintf", "vfscanf", WARN_UNSAFE)` ?


https://reviews.llvm.org/D35068



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


[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I'm planning to work on a new patch this week.


https://reviews.llvm.org/D39562



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for the feedback!

In https://reviews.llvm.org/D43162#1022427, @rsmith wrote:

> This is the wrong way to deal with this. The only thing that should ever be 
> controlled by -W flags is whether the warnings in that group appear, not 
> whether warnings in other groups appear. The principle is that -W flags 
> should behave "as if" they filter the diagnostic output of Clang. (We 
> actually depend on this in the implicit modules implementation, to allow 
> modules to be reused in compilation modes where a different set of warning 
> flags is enabled.) `isIgnored` exists only to allow the computations leading 
> to the emission of a diagnostic to be skipped if the diagnostic will not 
> actually be emitted.


Aha, i see. To be noted, this is how it is currently already done for 
`warn_cxx98_compat_no_newline_eof`/`warn_no_newline_eof`
https://github.com/llvm-mirror/clang/blob/f828172bcfd7d6d10497c645c3cc5eee321cd669/lib/Lex/Lexer.cpp#L2684-L2695
https://github.com/llvm-mirror/clang/blob/f828172bcfd7d6d10497c645c3cc5eee321cd669/include/clang/Basic/DiagnosticLexKinds.td#L58-L63
So i'm guessing that^ should be fixed too?

> The right thing to do is to add a new warning group for the 
> `warn_cxx98_compat_top_level_semi` warning, and make that a subgroup of the 
> `-Wextra-semi` group. That way `-Wno-extra-semi` can be used to turn off both 
> the C++98 extension warning and the C++11 compatibility warning. Take a look 
> at the `*BinaryLiteral` warning groups for an example of how to do this. 
> (That case is a little more complex because there's also a warning group for 
> the corresponding case in C.)

I'll look into it, but *right now* this sounds like it won't do what i'm trying 
to do here. Hopefully i'm just missing the point :)


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This one is abandoned. The new phab review is here:

https://reviews.llvm.org/D43841


https://reviews.llvm.org/D43839



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This is the wrong way to deal with this. The only thing that should ever be 
controlled by -W flags is whether the warnings in that group appear, not 
whether warnings in other groups appear. The principle is that -W flags should 
behave "as if" they filter the diagnostic output of Clang. (We actually depend 
on this in the implicit modules implementation, to allow modules to be reused 
in compilation modes where a different set of warning flags is enabled.) 
`isIgnored` exists only to allow the computations leading to the emission of a 
diagnostic to be skipped if the diagnostic will not actually be emitted.

The right thing to do is to add a new warning group for the 
`warn_cxx98_compat_top_level_semi` warning, and make that a subgroup of the 
`-Wextra-semi` group. That way `-Wno-extra-semi` can be used to turn off both 
the C++98 extension warning and the C++11 compatibility warning. Take a look at 
the `*BinaryLiteral` warning groups for an example of how to do this. (That 
case is a little more complex because there's also a warning group for the 
corresponding case in C.)


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Abandon this one, then, please.


https://reviews.llvm.org/D43839



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


[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

The issue is still observed in trunk. Other compilers process the tests 
correctly (checked using https://godbolt.org/). For instance, the code:

  template struct C20 {
  friend void func_20() {} // expected-note{{previous definition is here}}
  };
  C20 c20i;
  void func_20() {} // expected-error{{redefinition of 'func_20'}}

is rejected by gcc 7.3:

  : In function 'void func_20()':
  :5:6: error: redefinition of 'void func_20()'
   void func_20() {} // expected-error{{redefinition of 'func_20'}}
^~~
  :2:13: note: 'void func_20()' previously declared here
   friend void func_20() {} // expected-note{{previous definition is here}}
   ^~~
  Compiler returned: 1

by ICC 18:

  (5): error: function "func_20" has already been defined
void func_20() {} // expected-error{{redefinition of 'func_20'}}
 ^
  compilation aborted for  (code 2)
  Compiler returned: 2

and by MSVC 19 2017:

  (5): error C2084: function 'void C20::func_20(void)' already has 
a body
  (2): note: see previous definition of 'func_20'
  Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  Compiler returned: 2


https://reviews.llvm.org/D30170



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


[PATCH] D43870: [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

2018-02-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- The 'misc-undelegated-constructor' check was renamed to 
`bugprone-undelegated-constructor
+  
`_

Please sort checks alphabetically. Will be also good idea to move renamed 
checks after new checks/modules.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43870



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


  1   2   >