[PATCH] D51426: [Sema] Prohibit function-scope compound literals with address spaces.

2018-08-29 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:5745
+// C99 6.5.2.5p6: Function scope compound literals must have automatic
+// storage which generally excludes address space-qualified ones.
+Diag(LParenLoc, diag::err_compound_literal_with_address_space)

rjmccall wrote:
> Usually when we mention a standard section like this, it's a prelude to a 
> quote.  If you're just paraphrasing, I think we can trust people to find the 
> right standard section.
Hm, alright. I figured it was better to both provide the exact section and also 
include a summary here so you don't have to look it up.

Should I change it or is it good anyway?


Repository:
  rC Clang

https://reviews.llvm.org/D51426



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


[PATCH] D49074: [Analyzer] [WIP] Basic support for multiplication and division in the constraint manager

2018-08-29 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Disabled? No, that was a different thing. I have some ideas there as well, how 
to solve it, but it was the rearrangement in the `SValBuilder`. This one is one 
level lower, the `ConstraintManager` which only calculate the range for a 
symbol where we have and assumption for it. Here operations such as `Symbol + 
Integer1 <= Integer2` have been supported for many years (`+` can be `-` as 
well, similarily we can replace `<=` with any other comparison operator). This 
patch adds support for `*` and `/` so it extends support for expressions like 
`Symbol * Integer0 + Integer1 <= Integer2`. It has marginal impact on the 
performance, a constant and surely not exponential.


https://reviews.llvm.org/D49074



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


[PATCH] D51434: [HIP] Add -fvisibility hidden option to clang

2018-08-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:256
+CC1Args.append({"-fvisibility", "hidden"});
 }
 

We should probably start subclassing the HIP toolchain from AMDGPU and share 
more of this


https://reviews.llvm.org/D51434



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


[PATCH] D51390: [analyzer] CallDescription: Improve array management.

2018-08-29 Thread Henry Wong via Phabricator via cfe-commits
MTC accepted this revision.
MTC added a comment.

Thank you for digging in to delete that meaningless constructor, NoQ! And sorry 
for my technology debt : ).


Repository:
  rC Clang

https://reviews.llvm.org/D51390



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


[PATCH] D51473: Improve attribute documentation to list which spellings are used in which syntaxes.

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Instead of listing all the spellings (including attribute namespaces) in
the section heading, only list the actual attribute names there, and
list the spellings in the supported syntaxes table.

This allows us to properly describe things like [[fallthrough]], for
which we allow a clang:: prefix in C++ but not in C, and AlwaysInline,
which has one spelling as a GNU attribute and a different spelling as a
keyword, without needing to repeat the syntax description in the
documentation text.

Sample rendering: https://pste.eu/p/T1ZV.html


Repository:
  rC Clang

https://reviews.llvm.org/D51473

Files:
  include/clang/Basic/AttrDocs.td
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -3747,18 +3747,66 @@
   getPragmaAttributeSupport(Records).generateParsingHelpers(OS);
 }
 
+enum class SpellingKind {
+  GNU,
+  CXX11,
+  C2x,
+  Declspec,
+  Microsoft,
+  Keyword,
+  Pragma,
+};
+static const size_t NumSpellingKinds = (size_t)SpellingKind::Pragma + 1;
+
+class SpellingList {
+  std::vector Spellings[NumSpellingKinds];
+
+public:
+  ArrayRef operator[](SpellingKind K) const {
+return Spellings[(size_t)K];
+  }
+
+  void add(const Record &Attr, FlattenedSpelling Spelling) {
+SpellingKind Kind = StringSwitch(Spelling.variety())
+.Case("GNU", SpellingKind::GNU)
+.Case("CXX11", SpellingKind::CXX11)
+.Case("C2x", SpellingKind::C2x)
+.Case("Declspec", SpellingKind::Declspec)
+.Case("Microsoft", SpellingKind::Microsoft)
+.Case("Keyword", SpellingKind::Keyword)
+.Case("Pragma", SpellingKind::Pragma);
+std::string Name;
+if (!Spelling.nameSpace().empty()) {
+  switch (Kind) {
+  case SpellingKind::CXX11:
+  case SpellingKind::C2x:
+Name = Spelling.nameSpace() + "::";
+break;
+  case SpellingKind::Pragma:
+Name = Spelling.nameSpace() + " ";
+break;
+  default:
+PrintFatalError(Attr.getLoc(), "Unexpected namespace in spelling");
+  }
+}
+Name += Spelling.name();
+
+Spellings[(size_t)Kind].push_back(Name);
+  }
+};
+
 class DocumentationData {
 public:
   const Record *Documentation;
   const Record *Attribute;
   std::string Heading;
-  unsigned SupportedSpellings;
+  SpellingList SupportedSpellings;
 
   DocumentationData(const Record &Documentation, const Record &Attribute,
-const std::pair HeadingAndKinds)
+std::pair HeadingAndSpellings)
   : Documentation(&Documentation), Attribute(&Attribute),
-Heading(std::move(HeadingAndKinds.first)),
-SupportedSpellings(HeadingAndKinds.second) {}
+Heading(std::move(HeadingAndSpellings.first)),
+SupportedSpellings(std::move(HeadingAndSpellings.second)) {}
 };
 
 static void WriteCategoryHeader(const Record *DocCategory,
@@ -3774,28 +3822,21 @@
   OS << "\n\n";
 }
 
-enum SpellingKind {
-  GNU = 1 << 0,
-  CXX11 = 1 << 1,
-  C2x = 1 << 2,
-  Declspec = 1 << 3,
-  Microsoft = 1 << 4,
-  Keyword = 1 << 5,
-  Pragma = 1 << 6
-};
-
-static std::pair
-GetAttributeHeadingAndSpellingKinds(const Record &Documentation,
-const Record &Attribute) {
+static std::pair
+GetAttributeHeadingAndSpellings(const Record &Documentation,
+const Record &Attribute) {
   // FIXME: there is no way to have a per-spelling category for the attribute
   // documentation. This may not be a limiting factor since the spellings
   // should generally be consistently applied across the category.
 
   std::vector Spellings = GetFlattenedSpellings(Attribute);
+  if (Spellings.empty())
+PrintFatalError(Attribute.getLoc(),
+"Attribute has no supported spellings; cannot be "
+"documented");
 
   // Determine the heading to be used for this attribute.
   std::string Heading = Documentation.getValueAsString("Heading");
-  bool CustomHeading = !Heading.empty();
   if (Heading.empty()) {
 // If there's only one spelling, we can simply use that.
 if (Spellings.size() == 1)
@@ -3819,76 +3860,42 @@
 PrintFatalError(Attribute.getLoc(),
 "This attribute requires a heading to be specified");
 
-  // Gather a list of unique spellings; this is not the same as the semantic
-  // spelling for the attribute. Variations in underscores and other non-
-  // semantic characters are still acceptable.
-  std::vector Names;
+  SpellingList SupportedSpellings;
+  for (const auto &I : Spellings)
+SupportedSpellings.add(Attribute, I);
 
-  unsigned Support

r341013 - Ensure canonical type is actually canonical.

2018-08-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Aug 29 18:57:52 2018
New Revision: 341013

URL: http://llvm.org/viewvc/llvm-project?rev=341013&view=rev
Log:
Ensure canonical type is actually canonical.

ASTContext::applyObjCProtocolQualifiers will return a canonical type when given
a canonical type and an array of canonical protocols.  If the protocols are not
canonical then the returned type is also not canonical.  Since a canonical type 
is needed, canonicalize the returned type before using it.  This later prevents
a type from having a non-canonical canonical type.

Added:
cfe/trunk/test/Modules/odr_hash.mm
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=341013&r1=341012&r2=341013&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 29 18:57:52 2018
@@ -4550,8 +4550,8 @@ ASTContext::getObjCTypeParamType(const O
 if (!protocols.empty()) {
   // Apply the protocol qualifers.
   bool hasError;
-  Canonical = applyObjCProtocolQualifiers(Canonical, protocols, hasError,
-  true/*allowOnPointerType*/);
+  Canonical = getCanonicalType(applyObjCProtocolQualifiers(
+  Canonical, protocols, hasError, true /*allowOnPointerType*/));
   assert(!hasError && "Error when apply protocol qualifier to bound type");
 }
   }

Added: cfe/trunk/test/Modules/odr_hash.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.mm?rev=341013&view=auto
==
--- cfe/trunk/test/Modules/odr_hash.mm (added)
+++ cfe/trunk/test/Modules/odr_hash.mm Wed Aug 29 18:57:52 2018
@@ -0,0 +1,74 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x objective-c++ %t/Inputs/first.h -fblocks 
-fobjc-arc
+// RUN: %clang_cc1 -fsyntax-only -x objective-c++ %t/Inputs/second.h -fblocks 
-fobjc-arc
+
+// Build module map file
+// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module SecondModule {">> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -x objective-c++ -I%t/Inputs -verify %s -fblocks 
-fobjc-arc
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+@protocol P1
+@end
+
+@interface I1
+@end
+
+@interface Interface1  {
+@public
+  T x;
+}
+@end
+#endif
+
+#if defined(FIRST)
+struct S {
+  Interface1 *I;
+  decltype(I->x) x;
+  int y;
+};
+#elif defined(SECOND)
+struct S {
+  Interface1 *I;
+  decltype(I->x) x;
+  bool y;
+};
+#else
+S s;
+// expected-error@second.h:* {{'S::y' from module 'SecondModule' is not 
present in definition of 'S' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'y' does not match}}
+#endif
+
+// Keep macros contained to one file.
+#ifdef FIRST
+#undef FIRST
+#endif
+
+#ifdef SECOND
+#undef SECOND
+#endif


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


[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

F7076011: image.png 


https://reviews.llvm.org/D51395



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


[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 163247.

https://reviews.llvm.org/D51395

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,13 @@
 stateMgr->getStoreManager().decrementReferenceCount(store);
 }
 
+long ProgramState::getID() const {
+  Optional Out = getStateManager().Alloc.identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
+  return *Out / alignof(ProgramState);
+}
+
 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
  StoreManagerCreator CreateSMgr,
  ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3141,7 +3141,8 @@
 }
 
 ProgramStateRef state = N->getState();
-Out << "\\|StateID: " << (const void*) state.get()
+Out << "\\|StateID: " << state->getID() << " ("
+<< (const void*) state.get() << ")"
 << " NodeID: " << (const void*) N << "\\|";
 
 state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,8 @@
 
   ~ProgramState();
 
+  long getID() const;
+
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
 return *stateMgr;


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,13 @@
 stateMgr->getStoreManager().decrementReferenceCount(store);
 }
 
+long ProgramState::getID() const {
+  Optional Out = getStateManager().Alloc.identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
+  return *Out / alignof(ProgramState);
+}
+
 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
  StoreManagerCreator CreateSMgr,
  ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3141,7 +3141,8 @@
 }
 
 ProgramStateRef state = N->getState();
-Out << "\\|StateID: " << (const void*) state.get()
+Out << "\\|StateID: " << state->getID() << " ("
+<< (const void*) state.get() << ")"
 << " NodeID: " << (const void*) N << "\\|";
 
 state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,8 @@
 
   ~ProgramState();
 
+  long getID() const;
+
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
 return *stateMgr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 163246.

https://reviews.llvm.org/D51395

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,13 @@
 stateMgr->getStoreManager().decrementReferenceCount(store);
 }
 
+long ProgramState::getID() const {
+  Optional Out = getStateManager().Alloc.identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
+  return *Out;
+}
+
 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
  StoreManagerCreator CreateSMgr,
  ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3141,7 +3141,8 @@
 }
 
 ProgramStateRef state = N->getState();
-Out << "\\|StateID: " << (const void*) state.get()
+Out << "\\|StateID: " << state->getID() << " ("
+<< (const void*) state.get() << ")"
 << " NodeID: " << (const void*) N << "\\|";
 
 state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,8 @@
 
   ~ProgramState();
 
+  long getID() const;
+
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
 return *stateMgr;


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,13 @@
 stateMgr->getStoreManager().decrementReferenceCount(store);
 }
 
+long ProgramState::getID() const {
+  Optional Out = getStateManager().Alloc.identifyObject(this);
+  assert(Out && "Wrong allocator used");
+  assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
+  return *Out;
+}
+
 ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
  StoreManagerCreator CreateSMgr,
  ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3141,7 +3141,8 @@
 }
 
 ProgramStateRef state = N->getState();
-Out << "\\|StateID: " << (const void*) state.get()
+Out << "\\|StateID: " << state->getID() << " ("
+<< (const void*) state.get() << ")"
 << " NodeID: " << (const void*) N << "\\|";
 
 state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,8 @@
 
   ~ProgramState();
 
+  long getID() const;
+
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
 return *stateMgr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30009: Add support for '#pragma clang attribute'

2018-08-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a subscriber: erik.pilkington.
dexonsmith added a comment.

In https://reviews.llvm.org/D30009#1218647, @rsmith wrote:

> One consequence of this patch (see https://reviews.llvm.org/rL341002) is that 
> adding documentation to an existing attribute //changes the behavior of 
> Clang//. That does not seem acceptable to me: documentation improvements 
> should not change which attributes we allow this pragma to appertain to.
>
> If we really want an "only documented attribtues can use this feature" rule 
> (and I'm really not convinced that is a useful rule to enforce


I also don't quite see why this is useful.

> ), I think the best way to do that is to add another flag on the Attr 
> instance in the .td file to opt the attribute out of `#pragma clang` support, 
> opt out all the undocumented attributes, and add an error to TableGen if we 
> find that an undocumented attribute has `#pragma clang` support enabled.

It seems arbitrary not to support an attribute from `#pragma clang attribute` 
just because it was once undocumented.  It does seem incrementally better, but 
still not great.

(FYI, @arphaman is on vacation until next week so he's unlikely to respond 
promptly.)


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D30009#1218647, @rsmith wrote:

> One consequence of this patch (see https://reviews.llvm.org/rL341002) is that 
> adding documentation to an existing attribute //changes the behavior of 
> Clang//. That does not seem acceptable to me: documentation improvements 
> should not change which attributes we allow this pragma to appertain to.
>
> If we really want an "only documented attribtues can use this feature" rule 
> (and I'm really not convinced that is a useful rule to enforce), I think the 
> best way to do that is to add another flag on the Attr instance in the .td 
> file to opt the attribute out of `#pragma clang` support, opt out all the 
> undocumented attributes, and add an error to TableGen if we find that an 
> undocumented attribute has `#pragma clang` support enabled.


I've changed how we determine whether `#pragma clang attribute` is usable in 
https://reviews.llvm.org/rL341009 so that future documentation changes don't 
change clang's behavior. But we should still consider whether the attributes 
that were explicitly opted out of this feature in that revision really should 
be. What harm does allowing this feature for attributes that we don't document 
do? Most of those attributes are documented by GCC anyway, and the user 
experience of opting them out seems inconsistent and arbitrary. If the goal is 
to use this pragma as a forcing function to get documentation written for the 
attributes, it hasn't worked.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


r341009 - Adjust Attr representation so that changes to documentation don't affect

2018-08-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug 29 18:01:07 2018
New Revision: 341009

URL: http://llvm.org/viewvc/llvm-project?rev=341009&view=rev
Log:
Adjust Attr representation so that changes to documentation don't affect
how we parse source code.

Instead of implicitly opting all undocumented attributes out of '#pragma
clang attribute' support, explicitly opt them all out and remove the
documentation check from TableGen.

(No new attributes should be added without documentation, so this has
little chance of backsliding. We already support the pragma on one
undocumented attribute, so we don't even want to enforce our old
"rule".)

No functionality change intended.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=341009&r1=341008&r2=341009&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Aug 29 18:01:07 2018
@@ -473,13 +473,12 @@ class Attr {
   // in a class template definition.
   bit MeaningfulToClassTemplateDefinition = 0;
   // Set to true if this attribute can be used with '#pragma clang attribute'.
-  // By default, when this value is false, an attribute is supported by the
-  // '#pragma clang attribute' only when:
-  // - It has documentation.
+  // By default, an attribute is supported by the '#pragma clang attribute'
+  // only when:
   // - It has a subject list whose subjects can be represented using subject
   //   match rules.
   // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
-  bit ForcePragmaAttributeSupport = 0;
+  bit PragmaAttributeSupport;
   // Lists language options, one of which is required to be true for the
   // attribute to be applicable. If empty, no language options are required.
   list LangOpts = [];
@@ -546,6 +545,7 @@ class IgnoredAttr : Attr {
   let ASTNode = 0;
   let SemaHandler = 0;
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 //
@@ -564,6 +564,7 @@ def AddressSpace : TypeAttr {
   let Spellings = [Clang<"address_space">];
   let Args = [IntArgument<"AddressSpace">];
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Alias : Attr {
@@ -571,6 +572,7 @@ def Alias : Attr {
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Aligned : InheritableAttr {
@@ -583,6 +585,7 @@ def Aligned : InheritableAttr {
   Keyword<"_Alignas">]>,
Accessor<"isDeclspec",[Declspec<"align">]>];
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def AlignValue : Attr {
@@ -610,12 +613,14 @@ def AlignMac68k : InheritableAttr {
   let Spellings = [];
   let SemaHandler = 0;
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Artificial : InheritableAttr {
@@ -661,6 +666,7 @@ def AnalyzerNoReturn : InheritableAttr {
   // analyzer?
   let Spellings = [GNU<"analyzer_noreturn">];
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Annotate : InheritableParamAttr {
@@ -668,7 +674,7 @@ def Annotate : InheritableParamAttr {
   let Args = [StringArgument<"Annotation">];
   // Ensure that the annotate attribute can be used with
   // '#pragma clang attribute' even though it has no subject list.
-  let ForcePragmaAttributeSupport = 1;
+  let PragmaAttributeSupport = 1;
   let Documentation = [Undocumented];
 }
 
@@ -703,6 +709,7 @@ def AsmLabel : InheritableAttr {
   let Args = [StringArgument<"Label">];
   let SemaHandler = 0;
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Availability : InheritableAttr {
@@ -769,6 +776,7 @@ def Blocks : InheritableAttr {
   let Spellings = [Clang<"blocks">];
   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 def Bounded : IgnoredAttr {
@@ -787,6 +795,7 @@ def CDecl : DeclOrTypeAttr {
   let Spellings = [GCC<"cdecl">, Keyword<"__cdecl">, Keyword<"_cdecl">];
 //  let Subjects = [Function, ObjCMethod];
   let Documentation = [Undocumented];
+  let PragmaAttributeSupport = 0;
 }
 
 // cf_audited_transfer indicates that the given function has been
@@ -797,6 +806,7 @@ def CFAuditedTransfer : InheritableAttr
   let Spellings = [Clang<"cf_audited_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Un

[PATCH] D30009: Add support for '#pragma clang attribute'

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.
Herald added a subscriber: llvm-commits.

One consequence of this patch (see https://reviews.llvm.org/rL341002) is that 
adding documentation to an existing attribute //changes the behavior of 
Clang//. That does not seem acceptable to me: documentation improvements should 
not change which attributes we allow this pragma to appertain to.

If we really want an "only documented attribtues can use this feature" rule 
(and I'm really not convinced that is a useful rule to enforce), I think the 
best way to do that is to add another flag on the Attr instance in the .td file 
to opt the attribute out of `#pragma clang` support, opt out all the 
undocumented attributes, and add an error to TableGen if we find that an 
undocumented attribute has `#pragma clang` support enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

BTW, seems like these docs have tests that weren't updated. Fixed with 
https://reviews.llvm.org/rL341002, but please take a look if that's not the 
right fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D51190



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


r341002 - [AttrDocs] Fix build bots: add missing GNUInline pragma to test.

2018-08-29 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Wed Aug 29 17:04:34 2018
New Revision: 341002

URL: http://llvm.org/viewvc/llvm-project?rev=341002&view=rev
Log:
[AttrDocs] Fix build bots: add missing GNUInline pragma to test.

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=341002&r1=341001&r2=341002&view=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Wed Aug 
29 17:04:34 2018
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 74 attributes:
+// CHECK: #pragma clang attribute supports 75 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,7 @@
 // CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, 
SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, 
SubjectMatchRule_function, SubjectMatchRule_namespace, 
SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, 
SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, 
SubjectMatchRule_objc_protocol, SubjectMatchRule_record, 
SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)
 // CHECK-NEXT: Flatten (SubjectMatchRule_function)
+// CHECK-NEXT: GNUInline (SubjectMatchRule_function)
 // CHECK-NEXT: IFunc (SubjectMatchRule_function)
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, 
SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)


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


Buildbot numbers for the week of 8/12/2018 - 8/18/2018

2018-08-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 8/12/2018 - 8/18/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   | was_red
-+-
 clang-cmake-aarch64-lld | 87:39:15
 clang-cmake-armv7-full  | 62:31:05
 clang-x64-ninja-win7| 61:38:17
 clang-x86-windows-msvc2015  | 61:24:41
 clang-cmake-armv8-quick | 60:39:46
 clang-cmake-aarch64-global-isel | 60:25:12
 clang-cmake-armv8-full  | 60:16:05
 clang-cmake-armv8-global-isel   | 60:09:44
 clang-cmake-aarch64-quick   | 58:05:47
 lldb-amd64-ninja-netbsd8| 52:52:42
 clang-cmake-armv7-quick | 52:35:33
 clang-cmake-armv7-global-isel   | 51:53:59
 clang-x86_64-linux-abi-test | 50:10:12
 llvm-clang-x86_64-expensive-checks-win  | 34:21:28
 clang-lld-x86_64-2stage | 32:01:48
 sanitizer-x86_64-linux-bootstrap-ubsan  | 25:18:42
 clang-cuda-build| 25:17:38
 clang-x86_64-linux-selfhost-modules | 20:54:18
 clang-with-thin-lto-ubuntu  | 20:45:47
 clang-ppc64be-linux-multistage  | 20:40:01
 clang-hexagon-elf   | 20:31:08
 clang-with-lto-ubuntu   | 20:20:38
 clang-ppc64be-linux-lnt | 20:06:39
 clang-ppc64be-linux | 19:59:02
 clang-ppc64le-linux-lnt | 19:51:05
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 19:48:49
 clang-cmake-x86_64-avx2-linux   | 19:47:22
 clang-cmake-x86_64-sde-avx512-linux | 19:42:36
 clang-cmake-aarch64-full| 19:29:54
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 19:27:21
 clang-cmake-thumbv8-full-sh | 19:25:18
 clang-ppc64le-linux | 19:15:21
 reverse-iteration   | 18:36:07
 clang-cmake-armv8-selfhost-neon | 18:33:46
 clang-ppc64le-linux-multistage  | 18:07:47
 clang-cmake-thumbv7-full-sh | 17:01:50
 clang-cmake-armv7-selfhost  | 14:58:56
 clang-cmake-armv7-selfhost-neon | 14:35:12
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 12:32:40
 sanitizer-x86_64-linux-fast | 11:56:48
 libcxx-libcxxabi-libunwind-armv8-linux  | 11:02:31
 sanitizer-x86_64-linux-bootstrap| 11:02:17
 libcxx-libcxxabi-libunwind-aarch64-linux| 11:01:52
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 11:01:00
 libcxx-libcxxabi-libunwind-armv7-linux  | 10:55:10
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 10:52:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 10:48:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 10:47:32
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 10:46:28
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 10:46:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 10:45:59
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17  | 10:45:33
 lldb-x86_64-ubuntu-14.04-cmake  | 07:10:00
 sanitizer-ppc64le-linux | 05:32:03
 sanitizer-x86_64-linux-bootstrap-msan   | 04:37:05
 clang-tools-sphinx-docs | 04:32:56
 clang-cmake-x86_64-avx2-linux-perf  | 03:59:49
 clang-cmake-armv8-lnt   | 03:45:30
 sanitizer-ppc64be-linux | 03:40:56
 lldb-windows7-android   | 03:25:35
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 03:24:55
 sanitizer-x86_64-linux  | 03:16:35
 clang-cmake-armv7-lnt

Buildbot numbers for the week of 8/19/2018 - 8/25/2018

2018-08-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 8/19/2018 - 8/25/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
buildername|  was_red
---+--
 clang-hexagon-elf | 101:56:59
 llvm-hexagon-elf  | 99:32:47
 aosp-O3-polly-before-vectorizer-unprofitable  | 96:47:48
 clang-cmake-aarch64-quick | 48:49:28
 clang-lld-x86_64-2stage   | 36:16:20
 clang-with-lto-ubuntu | 34:35:38
 sanitizer-x86_64-linux-bootstrap  | 32:52:44
 sanitizer-x86_64-linux-bootstrap-ubsan| 32:06:51
 clang-with-thin-lto-ubuntu| 32:05:53
 llvm-clang-x86_64-expensive-checks-win| 28:03:52
 clang-x86-windows-msvc2015| 27:42:25
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 27:03:45
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 27:02:27
 sanitizer-x86_64-linux-bootstrap-msan | 26:54:06
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 23:51:40
 clang-cmake-aarch64-lld   | 21:30:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 20:51:44
 clang-x86_64-linux-selfhost-modules   | 18:28:13
 clang-ppc64le-linux-lnt   | 16:04:38
 sanitizer-x86_64-linux-fuzzer | 15:09:20
 sanitizer-x86_64-linux| 15:05:41
 clang-cmake-thumbv8-full-sh   | 14:48:39
 clang-cmake-armv8-selfhost-neon   | 12:47:43
 clang-cmake-armv7-selfhost-neon   | 12:39:37
 clang-cmake-armv7-selfhost| 12:39:31
 sanitizer-x86_64-linux-fast   | 12:22:32
 clang-ppc64le-linux-multistage| 10:56:35
 clang-cmake-aarch64-global-isel   | 09:32:55
 clang-ppc64be-linux-lnt   | 09:29:06
 clang-ppc64be-linux   | 09:27:13
 clang-cmake-armv8-quick   | 09:26:18
 clang-ppc64be-linux-multistage| 09:23:55
 lldb-amd64-ninja-netbsd8  | 09:18:53
 clang-cmake-armv8-full| 09:15:46
 clang-ppc64le-linux   | 09:13:56
 clang-cmake-armv7-global-isel | 09:00:32
 clang-cmake-armv7-quick   | 08:42:05
 clang-cmake-armv8-global-isel | 08:41:53
 clang-x86_64-debian-fast  | 08:18:34
 clang-cmake-aarch64-full  | 07:55:32
 clang-cmake-armv7-full| 07:24:20
 reverse-iteration | 06:51:23
 clang-cuda-build  | 06:50:09
 clang-cmake-thumbv7-full-sh   | 06:27:45
 clang-x64-ninja-win7  | 04:45:20
 sanitizer-ppc64le-linux   | 03:58:07
 sanitizer-windows | 03:54:52
 lldb-windows7-android | 02:57:38
 sanitizer-ppc64be-linux   | 02:46:12
 lldb-x86-windows-msvc2015 | 02:37:22
 sanitizer-x86_64-linux-autoconf   | 02:12:00
 clang-cmake-armv7-lnt | 02:04:57
 lld-x86_64-darwin13   | 01:55:06
 clang-cmake-x86_64-avx2-linux-perf| 01:37:41
 clang-cmake-armv8-lnt | 01:19:55
 lld-x86_64-freebsd| 01:19:11
 lldb-x86_64-ubuntu-14.04-buildserver  | 01:12:28
 lld-perf-testsuite| 01:07:51
 clang-cmake-x86_64-avx2-linux | 01:04:07
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 01:04:01
 clang-cmake-x86_64-sde-avx512-linux   | 00:51:17
 clang-sphinx-docs | 00:36:17
 clang-aarch64-linux-build-cache   | 00:27:38
 polly-arm-linux   | 00:26:35
 clang-armv7-linux-build-cache | 00:25:47
 polly-amd64-linux | 00:24:26
 sanitizer-x86_64-linux-android| 00:23:16
 clang-x86_64-linux-abi-test   | 00:20:28
 lldb-amd64-ninja-freebsd1

[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D51393#1218544, @george.karpenkov wrote:

> In fact, generating a single "long" seems even better.


`ptrdiff_t` seems to express what we're trying to say pretty accurately.


https://reviews.llvm.org/D51393



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


[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 163224.
george.karpenkov edited the summary of this revision.
george.karpenkov added a comment.

In fact, generating a single "long" seems even better.


https://reviews.llvm.org/D51393

Files:
  llvm/include/llvm/Support/Allocator.h


Index: llvm/include/llvm/Support/Allocator.h
===
--- llvm/include/llvm/Support/Allocator.h
+++ llvm/include/llvm/Support/Allocator.h
@@ -21,6 +21,7 @@
 #ifndef LLVM_SUPPORT_ALLOCATOR_H
 #define LLVM_SUPPORT_ALLOCATOR_H
 
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -283,6 +284,34 @@
 
   size_t GetNumSlabs() const { return Slabs.size() + CustomSizedSlabs.size(); }
 
+  /// \return An index uniquely and reproducibly identifying
+  /// an input pointer \p Ptr in the given allocator.
+  /// The returned value is negative iff the object is inside a custom-size
+  /// slab.
+  /// Returns an empty optional if the pointer is not found in the allocator.
+  llvm::Optional identifyObject(const void *Ptr) {
+const char *P = reinterpret_cast(Ptr);
+long InSlabIdx = 0;
+for (size_t Idx = 0; Idx < Slabs.size(); Idx++) {
+  const char *S = reinterpret_cast(Slabs[Idx]);
+  if (P >= S && P < S + computeSlabSize(Idx))
+return InSlabIdx + (P - S);
+  InSlabIdx += computeSlabSize(Idx);
+}
+
+// Use negative index to denote custom sized slabs.
+long InCustomSizedSlabIdx = 0;
+for (size_t Idx = 0; Idx < CustomSizedSlabs.size(); Idx++) {
+  const char *S =
+  reinterpret_cast(CustomSizedSlabs[Idx].first);
+  size_t Size = CustomSizedSlabs[Idx].second;
+  if (P >= S && P < S + Size)
+return InCustomSizedSlabIdx - (P - S);
+  InCustomSizedSlabIdx -= Size;
+}
+return None;
+  }
+
   size_t getTotalMemory() const {
 size_t TotalMemory = 0;
 for (auto I = Slabs.begin(), E = Slabs.end(); I != E; ++I)


Index: llvm/include/llvm/Support/Allocator.h
===
--- llvm/include/llvm/Support/Allocator.h
+++ llvm/include/llvm/Support/Allocator.h
@@ -21,6 +21,7 @@
 #ifndef LLVM_SUPPORT_ALLOCATOR_H
 #define LLVM_SUPPORT_ALLOCATOR_H
 
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -283,6 +284,34 @@
 
   size_t GetNumSlabs() const { return Slabs.size() + CustomSizedSlabs.size(); }
 
+  /// \return An index uniquely and reproducibly identifying
+  /// an input pointer \p Ptr in the given allocator.
+  /// The returned value is negative iff the object is inside a custom-size
+  /// slab.
+  /// Returns an empty optional if the pointer is not found in the allocator.
+  llvm::Optional identifyObject(const void *Ptr) {
+const char *P = reinterpret_cast(Ptr);
+long InSlabIdx = 0;
+for (size_t Idx = 0; Idx < Slabs.size(); Idx++) {
+  const char *S = reinterpret_cast(Slabs[Idx]);
+  if (P >= S && P < S + computeSlabSize(Idx))
+return InSlabIdx + (P - S);
+  InSlabIdx += computeSlabSize(Idx);
+}
+
+// Use negative index to denote custom sized slabs.
+long InCustomSizedSlabIdx = 0;
+for (size_t Idx = 0; Idx < CustomSizedSlabs.size(); Idx++) {
+  const char *S =
+  reinterpret_cast(CustomSizedSlabs[Idx].first);
+  size_t Size = CustomSizedSlabs[Idx].second;
+  if (P >= S && P < S + Size)
+return InCustomSizedSlabIdx - (P - S);
+  InCustomSizedSlabIdx -= Size;
+}
+return None;
+  }
+
   size_t getTotalMemory() const {
 size_t TotalMemory = 0;
 for (auto I = Slabs.begin(), E = Slabs.end(); I != E; ++I)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:448-449
 
   Loc ThisLoc = Context.getSValBuilder().getCXXThis(CtorDecl->getParent(),
 Context.getStackFrame());
 

Szelethus wrote:
> NoQ wrote:
> > This totally needs `assert(CtorDecl == 
> > Context.getStackFrame()->getDecl())`. Otherwise we're in big trouble 
> > because we'll be looking into a this-region that doesn't exist on this 
> > stack frame.
> > 
> > On second thought, though, i guess we should put this assertion into the 
> > constructor of `CXXThisRegion`. I'll do this.
> > 
> > Also there's an overload of `getCXXThis` that accepts the method itself, no 
> > need to get parent.
> U that wouldn't be very nice, because...
Yeah, i guess i'll have to think a bit deeper about this. I really want to 
prevent invalid `CXXThisRegion`s from appearing, but it might be not that 
simple.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:456-483
 static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
   CheckerContext &Context) {
 
-  Optional CurrentObject = getObjectVal(Ctor, 
Context);
-  if (!CurrentObject)
+  const TypedValueRegion *CurrRegion = getConstructedRegion(Ctor, Context);
+  if (!CurrRegion)
 return false;
 

Szelethus wrote:
> ...`willBeAnalyzerLater()` relies on this, and it uses all sorts of 
> constructor decls to check whether `Context.getLocationContext()->getDecl()` 
> would be a subregion of another object. Are you sure that this is incorrect?
I mean not the this-region of the object, but the `CXXThisRegion` itself, in 
which this-region is stored. It is definitely not aliased across stack frames.


Repository:
  rC Clang

https://reviews.llvm.org/D51300



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


[libcxx] r340992 - Last week, someone noted that a couple of the time_point member functions were not constexpr. I looked, and they were right. They were made constexpr in p0505, so I looked at all th

2018-08-29 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug 29 16:02:15 2018
New Revision: 340992

URL: http://llvm.org/viewvc/llvm-project?rev=340992&view=rev
Log:
Last week, someone noted that a couple of the time_point member functions were 
not constexpr. I looked, and they were right. They were made constexpr in 
p0505, so I looked at all the other bits in that paper to make sure that I 
didn't miss anything else. There were a couple methods in the synopsis that 
should have been marked constexpr, but the code was correct.

Modified:
libcxx/trunk/include/chrono

libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp

libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp

Modified: libcxx/trunk/include/chrono
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=340992&r1=340991&r2=340992&view=diff
==
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Wed Aug 29 16:02:15 2018
@@ -77,16 +77,18 @@ public:
 
 constexpr common_type::type  operator+() const;
 constexpr common_type::type  operator-() const;
-constexpr duration& operator++();
-constexpr duration  operator++(int);
-constexpr duration& operator--();
-constexpr duration  operator--(int);
-
-constexpr duration& operator+=(const duration& d);
-constexpr duration& operator-=(const duration& d);
-
-duration& operator*=(const rep& rhs);
-duration& operator/=(const rep& rhs);
+constexpr duration& operator++();// constexpr in C++17
+constexpr duration  operator++(int); // constexpr in C++17
+constexpr duration& operator--();// constexpr in C++17
+constexpr duration  operator--(int); // constexpr in C++17
+
+constexpr duration& operator+=(const duration& d);  // constexpr in C++17
+constexpr duration& operator-=(const duration& d);  // constexpr in C++17
+
+duration& operator*=(const rep& rhs);   // constexpr in C++17
+duration& operator/=(const rep& rhs);   // constexpr in C++17
+duration& operator%=(const rep& rhs);   // constexpr in C++17
+duration& operator%=(const duration& rhs);  // constexpr in C++17
 
 // special values
 
@@ -127,8 +129,8 @@ public:
 
 // arithmetic
 
-time_point& operator+=(const duration& d);
-time_point& operator-=(const duration& d);
+time_point& operator+=(const duration& d); // constexpr in C++17
+time_point& operator-=(const duration& d); // constexpr in C++17
 
 // special values
 
@@ -1355,8 +1357,8 @@ public:
 
 // arithmetic
 
-_LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) 
{__d_ += __d; return *this;}
-_LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) 
{__d_ -= __d; return *this;}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& 
operator+=(const duration& __d) {__d_ += __d; return *this;}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& 
operator-=(const duration& __d) {__d_ -= __d; return *this;}
 
 // special values
 

Modified: 
libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_%2B%3D.pass.cpp?rev=340992&r1=340991&r2=340992&view=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
 Wed Aug 29 16:02:15 2018
@@ -12,15 +12,35 @@
 // time_point
 
 // time_point& operator+=(const duration& d);
+// constexpr in c++17
 
 #include 
 #include 
 
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+constexpr bool constexpr_test()
+{
+typedef std::chrono::system_clock Clock;
+typedef std::chrono::milliseconds Duration;
+std::chrono::time_point t(Duration(5));
+t += Duration(4);
+return t.time_since_epoch() == Duration(9);
+}
+#endif
+
 int main()
 {
+{
 typedef std::chrono::system_clock Clock;
 typedef std::chrono::milliseconds Duration;
 std::chrono::time_point t(Duration(3));
 t += Duration(2);
 assert(t.time_since_epoch() == Duration(5));
+}
+
+#if TEST_STD_VER > 14
+static_assert(constexpr_test(), "");
+#endif
 }

Modified: 
libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_-%3D.pass.cpp?rev=340992&r1=340991&r2=340992&view=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.point/tim

r340990 - [analyzer] Document that pointer arithmetic is not represented by SymExprs.

2018-08-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 29 15:57:52 2018
New Revision: 340990

URL: http://llvm.org/viewvc/llvm-project?rev=340990&view=rev
Log:
[analyzer] Document that pointer arithmetic is not represented by SymExprs.

Add assertions to verify that.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=340990&r1=340989&r2=340990&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Wed 
Aug 29 15:57:52 2018
@@ -763,7 +763,9 @@ class SymbolicRegion : public SubRegion
 
   SymbolicRegion(const SymbolRef s, const MemSpaceRegion *sreg)
   : SubRegion(sreg, SymbolicRegionKind), sym(s) {
-assert(s);
+// Because pointer arithmetic is represented by ElementRegion layers,
+// the base symbol here should not contain any arithmetic.
+assert(s && isa(s));
 assert(s->getType()->isAnyPointerType() ||
s->getType()->isReferenceType() ||
s->getType()->isBlockPointerType());

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=340990&r1=340989&r2=340990&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
Wed Aug 29 15:57:52 2018
@@ -309,7 +309,10 @@ protected:
   BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t)
   : SymExpr(k), Op(op), T(t) {
 assert(classof(this));
-assert(isValidTypeForSymbol(t));
+// Binary expressions are results of arithmetic. Pointer arithmetic is not
+// handled by binary expressions, but it is instead handled by applying
+// sub-regions to regions.
+assert(isValidTypeForSymbol(t) && !Loc::isLocType(t));
   }
 
 public:


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


[PATCH] D51390: [analyzer] CallDescription: Improve array management.

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yeah, i guess i should've split those up.

Well, i had to fix the other code when i fixed the first code, because it 
contains a hardcoded duplicate of the vector type. So i decided to fix it in a 
slightly more intelligent manner.


Repository:
  rC Clang

https://reviews.llvm.org/D51390



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


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-08-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added a reviewer: atanasyan.
Herald added subscribers: cfe-commits, jrtc27, arichardson, sdardis, srhines.

Guess N32 ABI when no abi option is given based on llvm patch.
It now support mips64(el)-linux-gnuabin32 and mipsn32(el).

The include and library paths are also added based on
Debian/Gcc scheme.


Repository:
  rC Clang

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -4,6 +4,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %cla

[PATCH] D51390: [analyzer] CallDescription: Improve array management.

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Strictly speaking those two seem like completely unrelated changes , right?


Repository:
  rC Clang

https://reviews.llvm.org/D51390



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


[PATCH] D50850: clang: Add triples support for MIPS r6

2018-08-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 163221.

Repository:
  rC Clang

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,6 +291,13 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
@@ -298,6 +305,13 @@
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,6 +337,13 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
@@ -330,6 +351,13 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
@@ -338,6 +366,14 @@
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
@@ -346,6 +382,14 @@
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
@@ -354,6 +398,14 @@
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
@@ -362,6 +414,14 @@
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -1,13 +1,21 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -e

[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340987: [AttrDocs]: document gnu_inline function attribute 
(authored by nickdesaulniers, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51190

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


Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,38 @@
 invoking clang with -fno-c++-static-destructors.
   }];
 }
+
+def GnuInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 and C++ inline semantics.
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+Some important consequences: ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default. It is
+unspecified which macro is defined in a C++ compilation.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+  }];
+}
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1168,7 +1168,7 @@
 def GNUInline : InheritableAttr {
   let Spellings = [GCC<"gnu_inline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [GnuInlineDocs];
 }
 
 def Hot : InheritableAttr {


Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,38 @@
 invoking clang with -fno-c++-static-destructors.
   }];
 }
+
+def GnuInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 and C++ inline semantics.
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+Some important consequences: ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default. It is
+unspecified which macro is defined in a C++ compilation.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+  }];
+}
Index: cfe/trunk/include/clang/Basic/Attr.td
==

r340987 - [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Wed Aug 29 15:50:47 2018
New Revision: 340987

URL: http://llvm.org/viewvc/llvm-project?rev=340987&view=rev
Log:
[AttrDocs]: document gnu_inline function attribute

Summary: This wasn't documented 
https://clang.llvm.org/docs/AttributeReference.html, and briefly mentioned 
https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: efriedma, cfe-commits, srhines

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

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

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=340987&r1=340986&r2=340987&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Aug 29 15:50:47 2018
@@ -1168,7 +1168,7 @@ def FormatArg : InheritableAttr {
 def GNUInline : InheritableAttr {
   let Spellings = [GCC<"gnu_inline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [GnuInlineDocs];
 }
 
 def Hot : InheritableAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=340987&r1=340986&r2=340987&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Aug 29 15:50:47 2018
@@ -3505,3 +3505,38 @@ static and thread duration variable with
 invoking clang with -fno-c++-static-destructors.
   }];
 }
+
+def GnuInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 and C++ inline semantics.
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+Some important consequences: ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default. It is
+unspecified which macro is defined in a C++ compilation.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+  }];
+}


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


[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Looks good, thanks for improving our documentation!


Repository:
  rC Clang

https://reviews.llvm.org/D51190



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


[PATCH] D51323: [analyzer] Improve tracing for uninitialized struct fields

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340986: [analyzer] Improve tracing for uninitialized struct 
fields (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51323?vs=162747&id=163217#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51323

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/uninit-vals-ps-region.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.c
  test/Analysis/uninit-vals.cpp
  test/Analysis/uninit-vals.m

Index: test/Analysis/uninit-vals.m
===
--- test/Analysis/uninit-vals.m
+++ test/Analysis/uninit-vals.m
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-output=text -verify %s
 
 typedef unsigned int NSUInteger;
 typedef __typeof__(sizeof(int)) size_t;
@@ -9,6 +9,112 @@
 
 void clang_analyzer_eval(int);
 
+struct s {
+  int data;
+};
+
+struct s global;
+
+void g(int);
+
+void f4() {
+  int a;
+  if (global.data == 0)
+a = 3;
+  if (global.data == 0) // When the true branch is feasible 'a = 3'.
+g(a); // no-warning
+}
+
+
+// Test uninitialized value due to part of the structure being uninitialized.
+struct TestUninit { int x; int y; };
+struct TestUninit test_uninit_aux();
+void test_unit_aux2(int);
+void test_uninit_pos() {
+  struct TestUninit v1 = { 0, 0 };
+  struct TestUninit v2 = test_uninit_aux();
+  int z; // expected-note{{'z' declared without an initial value}}
+  v1.y = z; // expected-warning{{Assigned value is garbage or undefined}}
+// expected-note@-1{{Assigned value is garbage or undefined}}
+  test_unit_aux2(v2.x + v1.y);
+}
+void test_uninit_pos_2() {
+  struct TestUninit v1 = { 0, 0 };
+  struct TestUninit v2;
+  test_unit_aux2(v2.x + v1.y);  // expected-warning{{The left operand of '+' is a garbage value}}
+// expected-note@-1{{The left operand of '+' is a garbage value}}
+}
+void test_uninit_pos_3() {
+  struct TestUninit v1 = { 0, 0 };
+  struct TestUninit v2;
+  test_unit_aux2(v1.y + v2.x);  // expected-warning{{The right operand of '+' is a garbage value}}
+// expected-note@-1{{The right operand of '+' is a garbage value}}
+}
+
+void test_uninit_neg() {
+  struct TestUninit v1 = { 0, 0 };
+  struct TestUninit v2 = test_uninit_aux();
+  test_unit_aux2(v2.x + v1.y);
+}
+
+extern void test_uninit_struct_arg_aux(struct TestUninit arg);
+void test_uninit_struct_arg() {
+  struct TestUninit x; // expected-note{{'x' initialized here}}
+  test_uninit_struct_arg_aux(x); // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+ // expected-note@-1{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+}
+
+@interface Foo
+- (void) passVal:(struct TestUninit)arg;
+@end
+void testFoo(Foo *o) {
+  struct TestUninit x; // expected-note{{'x' initialized here}}
+  [o passVal:x]; // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+ // expected-note@-1{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+}
+
+// Test case from .  That shows an uninitialized value
+// being used in the LHS of a compound assignment.
+void rdar_7780304() {
+  typedef struct s_r7780304 { int x; } s_r7780304;
+  s_r7780304 b;
+  b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
+// expected-note@-1{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
+}
+
+
+// The flip side of PR10163 -- float arrays that are actually uninitialized
+void test_PR10163(float);
+void PR10163 (void) {
+  float x[2];
+  test_PR10163(x[1]); // expected-warning{{uninitialized value}}
+  // expected-note@-1{{1st function call argument is an uninitialized value}}
+}
+
+// PR10163 -- don't warn for default-initialized float arrays.
+void PR10163_default_initialized_arrays(void) {
+  float x[2] = {0};
+  test_PR10163(x[1]); // no-warning  
+}
+
+struct MyStr {
+  int x;
+  int y;
+};
+void swap(struct MyStr *To, struct MyStr *From) {
+  // This is not really a swap but close enough for our test.
+  To->x = From->x;
+  To->y = From->y; // expected-note{{Uninitialized value stored to field 'y'}}
+}
+int test_undefined_member_assignment_in_swap(struct MyStr *s2) {
+  struct MyStr s1;
+  s1.x = 5;
+  swap(s2, &s1); // expected-note{{Calling 'swap'}}
+ // expected-note@-1{{Returning from 'swap'}}
+  return s2->y; // expect

r340986 - [analyzer] Improve tracing for uninitialized struct fields

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 15:48:50 2018
New Revision: 340986

URL: http://llvm.org/viewvc/llvm-project?rev=340986&view=rev
Log:
[analyzer] Improve tracing for uninitialized struct fields

rdar://13729267

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

Added:
cfe/trunk/test/Analysis/uninit-vals.c
Removed:
cfe/trunk/test/Analysis/uninit-vals-ps-region.m
cfe/trunk/test/Analysis/uninit-vals-ps.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/test/Analysis/uninit-vals.cpp
cfe/trunk/test/Analysis/uninit-vals.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=340986&r1=340985&r2=340986&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Wed Aug 29 
15:48:50 2018
@@ -304,6 +304,8 @@ bool CallAndMessageChecker::PreVisitProc
 auto R = llvm::make_unique(*BT, os.str(), N);
 R->addRange(ArgRange);
 
+if (ArgEx)
+  bugreporter::trackNullOrUndefValue(N, ArgEx, *R);
 // FIXME: enhance track back for uninitialized value for arbitrary
 // memregions
 C.emitReport(std::move(R));

Removed: cfe/trunk/test/Analysis/uninit-vals-ps-region.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps-region.m?rev=340985&view=auto
==
--- cfe/trunk/test/Analysis/uninit-vals-ps-region.m (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps-region.m (removed)
@@ -1,93 +0,0 @@
-// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core 
-verify %s
-
-struct s {
-  int data;
-};
-
-struct s global;
-
-void g(int);
-
-void f4() {
-  int a;
-  if (global.data == 0)
-a = 3;
-  if (global.data == 0) // When the true branch is feasible 'a = 3'.
-g(a); // no-warning
-}
-
-
-// Test uninitialized value due to part of the structure being uninitialized.
-struct TestUninit { int x; int y; };
-struct TestUninit test_uninit_aux();
-void test_unit_aux2(int);
-void test_uninit_pos() {
-  struct TestUninit v1 = { 0, 0 };
-  struct TestUninit v2 = test_uninit_aux();
-  int z;
-  v1.y = z; // expected-warning{{Assigned value is garbage or undefined}}
-  test_unit_aux2(v2.x + v1.y);
-}
-void test_uninit_pos_2() {
-  struct TestUninit v1 = { 0, 0 };
-  struct TestUninit v2;
-  test_unit_aux2(v2.x + v1.y);  // expected-warning{{The left operand of '+' 
is a garbage value}}
-}
-void test_uninit_pos_3() {
-  struct TestUninit v1 = { 0, 0 };
-  struct TestUninit v2;
-  test_unit_aux2(v1.y + v2.x);  // expected-warning{{The right operand of '+' 
is a garbage value}}
-}
-
-void test_uninit_neg() {
-  struct TestUninit v1 = { 0, 0 };
-  struct TestUninit v2 = test_uninit_aux();
-  test_unit_aux2(v2.x + v1.y);
-}
-
-extern void test_uninit_struct_arg_aux(struct TestUninit arg);
-void test_uninit_struct_arg() {
-  struct TestUninit x;
-  test_uninit_struct_arg_aux(x); // expected-warning{{Passed-by-value struct 
argument contains uninitialized data (e.g., field: 'x')}}
-}
-
-@interface Foo
-- (void) passVal:(struct TestUninit)arg;
-@end
-void testFoo(Foo *o) {
-  struct TestUninit x;
-  [o passVal:x]; // expected-warning{{Passed-by-value struct argument contains 
uninitialized data (e.g., field: 'x')}}
-}
-
-// Test case from .  That shows an uninitialized value
-// being used in the LHS of a compound assignment.
-void rdar_7780304() {
-  typedef struct s_r7780304 { int x; } s_r7780304;
-  s_r7780304 b;
-  b.x |= 1; // expected-warning{{The left expression of the compound 
assignment is an uninitialized value. The computed value will also be garbage}}
-}
-
-
-// The flip side of PR10163 -- float arrays that are actually uninitialized
-// (The main test is in uninit-vals.m)
-void test_PR10163(float);
-void PR10163 (void) {
-  float x[2];
-  test_PR10163(x[1]); // expected-warning{{uninitialized value}}
-}
-
-struct MyStr {
-  int x;
-  int y;
-};
-void swap(struct MyStr *To, struct MyStr *From) {
-  // This is not really a swap but close enough for our test.
-  To->x = From->x;
-  To->y = From->y; // no warning
-}
-int test_undefined_member_assignment_in_swap(struct MyStr *s2) {
-  struct MyStr s1;
-  s1.x = 5;
-  swap(s2, &s1);
-  return s2->y; // expected-warning{{Undefined or garbage value returned to 
caller}}
-}

Removed: cfe/trunk/test/Analysis/uninit-vals-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps.c?rev=340985&view=auto
==
--- cfe/trunk/test/Analysis/uninit-vals-ps.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c (removed)
@@ -1,157 +0,0 @@
-// RUN: %clang_analyz

[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 163215.
nickdesaulniers added a comment.

- link to correct doc
- explicitly mention extern inline
- s/c89/GNU inline extension/g and mention -std=gnu89/-fgnu89-inline
- Take rsmith's sugguested wording. Add info about __GNUC_STDC_INLINE__.
- some final touches recommended by rsmith


Repository:
  rC Clang

https://reviews.llvm.org/D51190

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,38 @@
 invoking clang with -fno-c++-static-destructors.
   }];
 }
+
+def GnuInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 and C++ inline semantics.
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+Some important consequences: ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default. It is
+unspecified which macro is defined in a C++ compilation.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+  }];
+}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1168,7 +1168,7 @@
 def GNUInline : InheritableAttr {
   let Spellings = [GCC<"gnu_inline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [GnuInlineDocs];
 }
 
 def Hot : InheritableAttr {


Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,38 @@
 invoking clang with -fno-c++-static-destructors.
   }];
 }
+
+def GnuInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 and C++ inline semantics.
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+Some important consequences: ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default. It is
+unspecified which macro is defined in a C++ compilation.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+  }];
+}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/At

r340984 - [analyzer] Support modeling no-op BaseToDerived casts in ExprEngine.

2018-08-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 29 15:43:31 2018
New Revision: 340984

URL: http://llvm.org/viewvc/llvm-project?rev=340984&view=rev
Log:
[analyzer] Support modeling no-op BaseToDerived casts in ExprEngine.

Introduce a new MemRegion sub-class, CXXDerivedObjectRegion, which is
the opposite of CXXBaseObjectRegion, to represent such casts. Such region is
a bit weird because it is by design bigger than its super-region.
But it's not harmful when it is put on top of a SymbolicRegion
that has unknown extent anyway.

Offset computation for CXXDerivedObjectRegion and proper modeling of casts
still remains to be implemented.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
cfe/trunk/test/Analysis/casts.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=340984&r1=340983&r2=340984&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Wed 
Aug 29 15:43:31 2018
@@ -122,7 +122,7 @@ public:
   /// Each region is a subregion of itself.
   virtual bool isSubRegionOf(const MemRegion *R) const;
 
-  const MemRegion *StripCasts(bool StripBaseCasts = true) const;
+  const MemRegion *StripCasts(bool StripBaseAndDerivedCasts = true) const;
 
   /// If this is a symbolic region, returns the region. Otherwise,
   /// goes up the base chain looking for the first symbolic base region.
@@ -1176,6 +1176,47 @@ public:
   }
 };
 
+// CXXDerivedObjectRegion represents a derived-class object that surrounds
+// a C++ object. It is identified by the derived class declaration and the
+// region of its parent object. It is a bit counter-intuitive (but not 
otherwise
+// unseen) that this region represents a larger segment of memory that its
+// super-region.
+class CXXDerivedObjectRegion : public TypedValueRegion {
+  friend class MemRegionManager;
+
+  const CXXRecordDecl *DerivedD;
+
+  CXXDerivedObjectRegion(const CXXRecordDecl *DerivedD, const SubRegion *SReg)
+  : TypedValueRegion(SReg, CXXDerivedObjectRegionKind), DerivedD(DerivedD) 
{
+assert(DerivedD);
+// In case of a concrete region, it should always be possible to model
+// the base-to-derived cast by undoing a previous derived-to-base cast,
+// otherwise the cast is most likely ill-formed.
+assert(SReg->getSymbolicBase() &&
+   "Should have unwrapped a base region instead!");
+  }
+
+  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl 
*RD,
+const MemRegion *SReg);
+
+public:
+  const CXXRecordDecl *getDecl() const { return DerivedD; }
+
+  QualType getValueType() const override;
+
+  void dumpToStream(raw_ostream &os) const override;
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+
+  bool canPrintPrettyAsExpr() const override;
+
+  void printPrettyAsExpr(raw_ostream &os) const override;
+
+  static bool classof(const MemRegion *region) {
+return region->getKind() == CXXDerivedObjectRegionKind;
+  }
+};
+
 template
 const RegionTy* MemRegion::getAs() const {
   if (const auto *RT = dyn_cast(this))
@@ -1326,6 +1367,14 @@ public:
   baseReg->isVirtual());
   }
 
+  /// Create a CXXDerivedObjectRegion with the given derived class for region
+  /// \p Super. This should not be used for casting an existing
+  /// CXXBaseObjectRegion back to the derived type; instead, 
CXXBaseObjectRegion
+  /// should be removed.
+  const CXXDerivedObjectRegion *
+  getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass,
+const SubRegion *Super);
+
   const FunctionCodeRegion *getFunctionCodeRegion(const NamedDecl *FD);
   const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD,
 CanQualType locTy,

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def?rev=340984&r1=340983&r2=340984&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def Wed 
Aug 29 15:43:31 2018
@@ -68,6 +68,7 @@ ABSTRACT_REGION(SubRegion, MemRegion)
 ABSTRACT_REGION(TypedValueRegion, TypedRegion)
   REGION(CompoundLiteralRegion, Type

[PATCH] D51191: [analyzer] Support modelling no-op BaseToDerived casts in ExprEngine

2018-08-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340984: [analyzer] Support modeling no-op BaseToDerived 
casts in ExprEngine. (authored by dergachev, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51191

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  lib/StaticAnalyzer/Core/MemRegion.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -122,7 +122,7 @@
   /// Each region is a subregion of itself.
   virtual bool isSubRegionOf(const MemRegion *R) const;
 
-  const MemRegion *StripCasts(bool StripBaseCasts = true) const;
+  const MemRegion *StripCasts(bool StripBaseAndDerivedCasts = true) const;
 
   /// If this is a symbolic region, returns the region. Otherwise,
   /// goes up the base chain looking for the first symbolic base region.
@@ -1176,6 +1176,47 @@
   }
 };
 
+// CXXDerivedObjectRegion represents a derived-class object that surrounds
+// a C++ object. It is identified by the derived class declaration and the
+// region of its parent object. It is a bit counter-intuitive (but not otherwise
+// unseen) that this region represents a larger segment of memory that its
+// super-region.
+class CXXDerivedObjectRegion : public TypedValueRegion {
+  friend class MemRegionManager;
+
+  const CXXRecordDecl *DerivedD;
+
+  CXXDerivedObjectRegion(const CXXRecordDecl *DerivedD, const SubRegion *SReg)
+  : TypedValueRegion(SReg, CXXDerivedObjectRegionKind), DerivedD(DerivedD) {
+assert(DerivedD);
+// In case of a concrete region, it should always be possible to model
+// the base-to-derived cast by undoing a previous derived-to-base cast,
+// otherwise the cast is most likely ill-formed.
+assert(SReg->getSymbolicBase() &&
+   "Should have unwrapped a base region instead!");
+  }
+
+  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl *RD,
+const MemRegion *SReg);
+
+public:
+  const CXXRecordDecl *getDecl() const { return DerivedD; }
+
+  QualType getValueType() const override;
+
+  void dumpToStream(raw_ostream &os) const override;
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+
+  bool canPrintPrettyAsExpr() const override;
+
+  void printPrettyAsExpr(raw_ostream &os) const override;
+
+  static bool classof(const MemRegion *region) {
+return region->getKind() == CXXDerivedObjectRegionKind;
+  }
+};
+
 template
 const RegionTy* MemRegion::getAs() const {
   if (const auto *RT = dyn_cast(this))
@@ -1326,6 +1367,14 @@
   baseReg->isVirtual());
   }
 
+  /// Create a CXXDerivedObjectRegion with the given derived class for region
+  /// \p Super. This should not be used for casting an existing
+  /// CXXBaseObjectRegion back to the derived type; instead, CXXBaseObjectRegion
+  /// should be removed.
+  const CXXDerivedObjectRegion *
+  getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass,
+const SubRegion *Super);
+
   const FunctionCodeRegion *getFunctionCodeRegion(const NamedDecl *FD);
   const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD,
 CanQualType locTy,
Index: include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
+++ include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
@@ -68,6 +68,7 @@
 ABSTRACT_REGION(TypedValueRegion, TypedRegion)
   REGION(CompoundLiteralRegion, TypedValueRegion)
   REGION(CXXBaseObjectRegion, TypedValueRegion)
+  REGION(CXXDerivedObjectRegion, TypedValueRegion)
   REGION(CXXTempObjectRegion, TypedValueRegion)
   REGION(CXXThisRegion, TypedValueRegion)
   ABSTRACT_REGION(DeclRegion, TypedValueRegion)
Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s
+
+void clang_analyzer_eval(bool);
 
 bool PR14634(int x) {
   double y = (double)x;
@@ -41,3 +43,32 @@
   *reinterpret_cast(&q) = p;
   return q;
 }
+
+namespace base_to_derived {
+struct A {};
+struct B : public A{};
+
+void foo(A* a) {
+  B* b = (B* ) a;
+  A* a2 = (A *) b;
+  clang_analyzer_eval(a2 == a); // expected-warning{{TRUE}}
+}
+}
+

r340982 - [analyzer] CFRetainReleaseChecker: Don't check C++ methods with the same name.

2018-08-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 29 15:39:20 2018
New Revision: 340982

URL: http://llvm.org/viewvc/llvm-project?rev=340982&view=rev
Log:
[analyzer] CFRetainReleaseChecker: Don't check C++ methods with the same name.

Don't try to understand what's going on when there's a C++ method called eg.
CFRetain().

Refactor the checker a bit, to use more modern APIs.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/test/Analysis/retain-release.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp?rev=340982&r1=340981&r2=340982&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Wed Aug 
29 15:39:20 2018
@@ -36,6 +36,7 @@
 
 using namespace clang;
 using namespace ento;
+using namespace llvm;
 
 namespace {
 class APIMisuse : public BugType {
@@ -531,93 +532,59 @@ void CFNumberChecker::checkPreStmt(const
 
//===--===//
 
 namespace {
-class CFRetainReleaseChecker : public Checker< check::PreStmt > {
-  mutable std::unique_ptr BT;
-  mutable IdentifierInfo *Retain, *Release, *MakeCollectable, *Autorelease;
+class CFRetainReleaseChecker : public Checker {
+  mutable APIMisuse BT{this, "null passed to CF memory management function"};
+  CallDescription CFRetain{"CFRetain", 1},
+  CFRelease{"CFRelease", 1},
+  CFMakeCollectable{"CFMakeCollectable", 1},
+  CFAutorelease{"CFAutorelease", 1};
 
 public:
-  CFRetainReleaseChecker()
-  : Retain(nullptr), Release(nullptr), MakeCollectable(nullptr),
-Autorelease(nullptr) {}
-  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 };
 } // end anonymous namespace
 
-void CFRetainReleaseChecker::checkPreStmt(const CallExpr *CE,
+void CFRetainReleaseChecker::checkPreCall(const CallEvent &Call,
   CheckerContext &C) const {
-  // If the CallExpr doesn't have exactly 1 argument just give up checking.
-  if (CE->getNumArgs() != 1)
-return;
-
-  ProgramStateRef state = C.getState();
-  const FunctionDecl *FD = C.getCalleeDecl(CE);
-  if (!FD)
+  // TODO: Make this check part of CallDescription.
+  if (!Call.isGlobalCFunction())
 return;
 
-  if (!BT) {
-ASTContext &Ctx = C.getASTContext();
-Retain = &Ctx.Idents.get("CFRetain");
-Release = &Ctx.Idents.get("CFRelease");
-MakeCollectable = &Ctx.Idents.get("CFMakeCollectable");
-Autorelease = &Ctx.Idents.get("CFAutorelease");
-BT.reset(new APIMisuse(
-this, "null passed to CF memory management function"));
-  }
-
   // Check if we called CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-  const IdentifierInfo *FuncII = FD->getIdentifier();
-  if (!(FuncII == Retain || FuncII == Release || FuncII == MakeCollectable ||
-FuncII == Autorelease))
+  if (!(Call.isCalled(CFRetain) || Call.isCalled(CFRelease) ||
+Call.isCalled(CFMakeCollectable) || Call.isCalled(CFAutorelease)))
 return;
 
-  // FIXME: The rest of this just checks that the argument is non-null.
-  // It should probably be refactored and combined with NonNullParamChecker.
-
   // Get the argument's value.
-  const Expr *Arg = CE->getArg(0);
-  SVal ArgVal = C.getSVal(Arg);
+  SVal ArgVal = Call.getArgSVal(0);
   Optional DefArgVal = ArgVal.getAs();
   if (!DefArgVal)
 return;
 
-  // Get a NULL value.
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedSVal zero =
-  svalBuilder.makeZeroVal(Arg->getType()).castAs();
-
-  // Make an expression asserting that they're equal.
-  DefinedOrUnknownSVal ArgIsNull = svalBuilder.evalEQ(state, zero, *DefArgVal);
-
-  // Are they equal?
-  ProgramStateRef stateTrue, stateFalse;
-  std::tie(stateTrue, stateFalse) = state->assume(ArgIsNull);
+  // Is it null?
+  ProgramStateRef state = C.getState();
+  ProgramStateRef stateNonNull, stateNull;
+  std::tie(stateNonNull, stateNull) = state->assume(*DefArgVal);
 
-  if (stateTrue && !stateFalse) {
-ExplodedNode *N = C.generateErrorNode(stateTrue);
+  if (!stateNonNull) {
+ExplodedNode *N = C.generateErrorNode(stateNull);
 if (!N)
   return;
 
-const char *description;
-if (FuncII == Retain)
-  description = "Null pointer argument in call to CFRetain";
-else if (FuncII == Release)
-  description = "Null pointer argument in call to CFRelease";
-else if (FuncII == MakeCollectable)
-  description = "Null pointer argument in call to CFMakeCollectable";
-else if (FuncII == Autorelease)
-  description = "N

[PATCH] D50866: [analyzer] CFRetainReleaseChecker: Avoid checking C++ methods with the same name.

2018-08-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340982: [analyzer] CFRetainReleaseChecker: Don't check 
C++ methods with the same name. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50866

Files:
  lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  test/Analysis/retain-release.mm

Index: test/Analysis/retain-release.mm
===
--- test/Analysis/retain-release.mm
+++ test/Analysis/retain-release.mm
@@ -470,3 +470,18 @@
 void rdar33832412() {
   void* x = IOBSDNameMatching(); // no-warning
 }
+
+
+namespace member_CFRetains {
+class Foo {
+public:
+  void CFRetain(const Foo &) {}
+  void CFRetain(int) {}
+};
+
+void bar() {
+  Foo foo;
+  foo.CFRetain(foo); // no-warning
+  foo.CFRetain(0); // no-warning
+}
+}
Index: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
===
--- lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -36,6 +36,7 @@
 
 using namespace clang;
 using namespace ento;
+using namespace llvm;
 
 namespace {
 class APIMisuse : public BugType {
@@ -531,93 +532,59 @@
 //===--===//
 
 namespace {
-class CFRetainReleaseChecker : public Checker< check::PreStmt > {
-  mutable std::unique_ptr BT;
-  mutable IdentifierInfo *Retain, *Release, *MakeCollectable, *Autorelease;
+class CFRetainReleaseChecker : public Checker {
+  mutable APIMisuse BT{this, "null passed to CF memory management function"};
+  CallDescription CFRetain{"CFRetain", 1},
+  CFRelease{"CFRelease", 1},
+  CFMakeCollectable{"CFMakeCollectable", 1},
+  CFAutorelease{"CFAutorelease", 1};
 
 public:
-  CFRetainReleaseChecker()
-  : Retain(nullptr), Release(nullptr), MakeCollectable(nullptr),
-Autorelease(nullptr) {}
-  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 };
 } // end anonymous namespace
 
-void CFRetainReleaseChecker::checkPreStmt(const CallExpr *CE,
+void CFRetainReleaseChecker::checkPreCall(const CallEvent &Call,
   CheckerContext &C) const {
-  // If the CallExpr doesn't have exactly 1 argument just give up checking.
-  if (CE->getNumArgs() != 1)
-return;
-
-  ProgramStateRef state = C.getState();
-  const FunctionDecl *FD = C.getCalleeDecl(CE);
-  if (!FD)
+  // TODO: Make this check part of CallDescription.
+  if (!Call.isGlobalCFunction())
 return;
 
-  if (!BT) {
-ASTContext &Ctx = C.getASTContext();
-Retain = &Ctx.Idents.get("CFRetain");
-Release = &Ctx.Idents.get("CFRelease");
-MakeCollectable = &Ctx.Idents.get("CFMakeCollectable");
-Autorelease = &Ctx.Idents.get("CFAutorelease");
-BT.reset(new APIMisuse(
-this, "null passed to CF memory management function"));
-  }
-
   // Check if we called CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-  const IdentifierInfo *FuncII = FD->getIdentifier();
-  if (!(FuncII == Retain || FuncII == Release || FuncII == MakeCollectable ||
-FuncII == Autorelease))
+  if (!(Call.isCalled(CFRetain) || Call.isCalled(CFRelease) ||
+Call.isCalled(CFMakeCollectable) || Call.isCalled(CFAutorelease)))
 return;
 
-  // FIXME: The rest of this just checks that the argument is non-null.
-  // It should probably be refactored and combined with NonNullParamChecker.
-
   // Get the argument's value.
-  const Expr *Arg = CE->getArg(0);
-  SVal ArgVal = C.getSVal(Arg);
+  SVal ArgVal = Call.getArgSVal(0);
   Optional DefArgVal = ArgVal.getAs();
   if (!DefArgVal)
 return;
 
-  // Get a NULL value.
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedSVal zero =
-  svalBuilder.makeZeroVal(Arg->getType()).castAs();
-
-  // Make an expression asserting that they're equal.
-  DefinedOrUnknownSVal ArgIsNull = svalBuilder.evalEQ(state, zero, *DefArgVal);
-
-  // Are they equal?
-  ProgramStateRef stateTrue, stateFalse;
-  std::tie(stateTrue, stateFalse) = state->assume(ArgIsNull);
+  // Is it null?
+  ProgramStateRef state = C.getState();
+  ProgramStateRef stateNonNull, stateNull;
+  std::tie(stateNonNull, stateNull) = state->assume(*DefArgVal);
 
-  if (stateTrue && !stateFalse) {
-ExplodedNode *N = C.generateErrorNode(stateTrue);
+  if (!stateNonNull) {
+ExplodedNode *N = C.generateErrorNode(stateNull);
 if (!N)
   return;
 
-const char *description;
-if (FuncII == Retain)
-  description = "Null pointer argument in call to CFRetain";
-else if (FuncII == Release)
-  description = "Null pointer argument in call to CFRelease";
-else if (FuncII == MakeCollectable)
-  description = "Null pointer argument in call to CFMakeCollectable";
-   

[PATCH] D50855: [analyzer] pr37578: Fix lvalue/rvalue problem in field-of-temporary adjustments.

2018-08-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340977: [CFG] [analyzer] Disable argument construction 
contexts for variadic functions. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50855?vs=162755&id=163202#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50855

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/temporaries.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -734,10 +734,14 @@
   ///
   /// If \p Result is provided, the new region will be bound to this expression
   /// instead of \p InitWithAdjustments.
-  ProgramStateRef createTemporaryRegionIfNeeded(ProgramStateRef State,
-const LocationContext *LC,
-const Expr *InitWithAdjustments,
-const Expr *Result = nullptr);
+  ///
+  /// Returns the temporary region with adjustments into the optional
+  /// OutRegionWithAdjustments out-parameter if a new region was indeed needed,
+  /// otherwise sets it to nullptr.
+  ProgramStateRef createTemporaryRegionIfNeeded(
+  ProgramStateRef State, const LocationContext *LC,
+  const Expr *InitWithAdjustments, const Expr *Result = nullptr,
+  const SubRegion **OutRegionWithAdjustments = nullptr);
 
   /// Returns a region representing the first element of a (possibly
   /// multi-dimensional) array, for the purposes of element construction or
Index: cfe/trunk/test/Analysis/temporaries.cpp
===
--- cfe/trunk/test/Analysis/temporaries.cpp
+++ cfe/trunk/test/Analysis/temporaries.cpp
@@ -1152,3 +1152,23 @@
 // and the non-definition decl should be found by direct lookup.
 void T::foo(C) {}
 } // namespace argument_virtual_decl_lookup
+
+namespace union_indirect_field_crash {
+union U {
+  struct {
+int x;
+  };
+};
+
+template  class C {
+public:
+  void foo() const {
+(void)(true ? U().x : 0);
+  }
+};
+
+void test() {
+  C c;
+  c.foo();
+}
+} // namespace union_indirect_field_crash
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -283,11 +283,10 @@
   return state;
 }
 
-ProgramStateRef
-ExprEngine::createTemporaryRegionIfNeeded(ProgramStateRef State,
-  const LocationContext *LC,
-  const Expr *InitWithAdjustments,
-  const Expr *Result) {
+ProgramStateRef ExprEngine::createTemporaryRegionIfNeeded(
+ProgramStateRef State, const LocationContext *LC,
+const Expr *InitWithAdjustments, const Expr *Result,
+const SubRegion **OutRegionWithAdjustments) {
   // FIXME: This function is a hack that works around the quirky AST
   // we're often having with respect to C++ temporaries. If only we modelled
   // the actual execution order of statements properly in the CFG,
@@ -297,8 +296,11 @@
   if (!Result) {
 // If we don't have an explicit result expression, we're in "if needed"
 // mode. Only create a region if the current value is a NonLoc.
-if (!InitValWithAdjustments.getAs())
+if (!InitValWithAdjustments.getAs()) {
+  if (OutRegionWithAdjustments)
+*OutRegionWithAdjustments = nullptr;
   return State;
+}
 Result = InitWithAdjustments;
   } else {
 // We need to create a region no matter what. For sanity, make sure we don't
@@ -418,11 +420,17 @@
   // The result expression would now point to the correct sub-region of the
   // newly created temporary region. Do this last in order to getSVal of Init
   // correctly in case (Result == Init).
-  State = State->BindExpr(Result, LC, Reg);
+  if (Result->isGLValue()) {
+State = State->BindExpr(Result, LC, Reg);
+  } else {
+State = State->BindExpr(Result, LC, InitValWithAdjustments);
+  }
 
   // Notify checkers once for two bindLoc()s.
   State = processRegionChange(State, TR, LC);
 
+  if (OutRegionWithAdjustments)
+*OutRegionWithAdjustments = cast(Reg.getAsRegion());
   return State;
 }
 
@@ -2532,8 +2540,12 @@
   }
 
   // Handle regular struct fields / member variables.
-  state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr);
-  SVal baseExprVal = state->getSVal(BaseExpr, LCtx);
+  const SubRegion *MR = nullptr;
+  state = createTemporaryRegionIfNeeded(s

r340977 - [CFG] [analyzer] Disable argument construction contexts for variadic functions.

2018-08-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 29 15:05:35 2018
New Revision: 340977

URL: http://llvm.org/viewvc/llvm-project?rev=340977&view=rev
Log:
[CFG] [analyzer] Disable argument construction contexts for variadic functions.

The analyzer doesn't make use of them anyway and they seem to have
pretty weird AST from time to time, so let's just skip them for now.

Fixes a crash reported as pr37769.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=340977&r1=340976&r2=340977&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Aug 29 15:05:35 2018
@@ -734,10 +734,14 @@ private:
   ///
   /// If \p Result is provided, the new region will be bound to this expression
   /// instead of \p InitWithAdjustments.
-  ProgramStateRef createTemporaryRegionIfNeeded(ProgramStateRef State,
-const LocationContext *LC,
-const Expr 
*InitWithAdjustments,
-const Expr *Result = nullptr);
+  ///
+  /// Returns the temporary region with adjustments into the optional
+  /// OutRegionWithAdjustments out-parameter if a new region was indeed needed,
+  /// otherwise sets it to nullptr.
+  ProgramStateRef createTemporaryRegionIfNeeded(
+  ProgramStateRef State, const LocationContext *LC,
+  const Expr *InitWithAdjustments, const Expr *Result = nullptr,
+  const SubRegion **OutRegionWithAdjustments = nullptr);
 
   /// Returns a region representing the first element of a (possibly
   /// multi-dimensional) array, for the purposes of element construction or

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=340977&r1=340976&r2=340977&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Aug 29 15:05:35 2018
@@ -283,11 +283,10 @@ ProgramStateRef ExprEngine::getInitialSt
   return state;
 }
 
-ProgramStateRef
-ExprEngine::createTemporaryRegionIfNeeded(ProgramStateRef State,
-  const LocationContext *LC,
-  const Expr *InitWithAdjustments,
-  const Expr *Result) {
+ProgramStateRef ExprEngine::createTemporaryRegionIfNeeded(
+ProgramStateRef State, const LocationContext *LC,
+const Expr *InitWithAdjustments, const Expr *Result,
+const SubRegion **OutRegionWithAdjustments) {
   // FIXME: This function is a hack that works around the quirky AST
   // we're often having with respect to C++ temporaries. If only we modelled
   // the actual execution order of statements properly in the CFG,
@@ -297,8 +296,11 @@ ExprEngine::createTemporaryRegionIfNeede
   if (!Result) {
 // If we don't have an explicit result expression, we're in "if needed"
 // mode. Only create a region if the current value is a NonLoc.
-if (!InitValWithAdjustments.getAs())
+if (!InitValWithAdjustments.getAs()) {
+  if (OutRegionWithAdjustments)
+*OutRegionWithAdjustments = nullptr;
   return State;
+}
 Result = InitWithAdjustments;
   } else {
 // We need to create a region no matter what. For sanity, make sure we 
don't
@@ -418,11 +420,17 @@ ExprEngine::createTemporaryRegionIfNeede
   // The result expression would now point to the correct sub-region of the
   // newly created temporary region. Do this last in order to getSVal of Init
   // correctly in case (Result == Init).
-  State = State->BindExpr(Result, LC, Reg);
+  if (Result->isGLValue()) {
+State = State->BindExpr(Result, LC, Reg);
+  } else {
+State = State->BindExpr(Result, LC, InitValWithAdjustments);
+  }
 
   // Notify checkers once for two bindLoc()s.
   State = processRegionChange(State, TR, LC);
 
+  if (OutRegionWithAdjustments)
+*OutRegionWithAdjustments = cast(Reg.getAsRegion());
   return State;
 }
 
@@ -2532,8 +2540,12 @@ void ExprEngine::VisitMemberExpr(const M
   }
 
   // Handle regular struct fields / member variables.
-  state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr);
-  SVal baseExprVal = state->getSVal(BaseExpr, LCtx);
+  const SubRegion *MR = nullptr;
+  state = createTemporaryRegionIfNeeded(state

[PATCH] D50824: [CFG] [analyzer] pr37769: Disable argument construction contexts for variadic functions.

2018-08-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340975: [CFG] [analyzer] Disable argument construction 
contexts for variadic functions. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50824?vs=160946&id=163200#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50824

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
@@ -1028,3 +1028,18 @@
   C(1) + C(2);
 }
 } // namespace operators
+
+namespace variadic_function_arguments {
+class C {
+ public:
+  C(int);
+};
+
+int variadic(...);
+
+// This code is quite exotic, so let's not test the CFG for it,
+// but only make sure we don't crash.
+void testCrashOnVariadicArgument() {
+  C c(variadic(0 ? c : 0)); // no-crash
+}
+} // namespace variadic_function_arguments
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -2421,8 +2421,6 @@
 if (!boundType.isNull()) calleeType = boundType;
   }
 
-  findConstructionContextsForArguments(C);
-
   // If this is a call to a no-return function, this stops the block here.
   bool NoReturn = getFunctionExtInfo(*calleeType).getNoReturn();
 
@@ -2439,6 +2437,13 @@
   bool OmitArguments = false;
 
   if (FunctionDecl *FD = C->getDirectCallee()) {
+// TODO: Support construction contexts for variadic function arguments.
+// These are a bit problematic and not very useful because passing
+// C++ objects as C-style variadic arguments doesn't work in general
+// (see [expr.call]).
+if (!FD->isVariadic())
+  findConstructionContextsForArguments(C);
+
 if (FD->isNoReturn() || C->isBuiltinAssumeFalse(*Context))
   NoReturn = true;
 if (FD->hasAttr())


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
@@ -1028,3 +1028,18 @@
   C(1) + C(2);
 }
 } // namespace operators
+
+namespace variadic_function_arguments {
+class C {
+ public:
+  C(int);
+};
+
+int variadic(...);
+
+// This code is quite exotic, so let's not test the CFG for it,
+// but only make sure we don't crash.
+void testCrashOnVariadicArgument() {
+  C c(variadic(0 ? c : 0)); // no-crash
+}
+} // namespace variadic_function_arguments
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -2421,8 +2421,6 @@
 if (!boundType.isNull()) calleeType = boundType;
   }
 
-  findConstructionContextsForArguments(C);
-
   // If this is a call to a no-return function, this stops the block here.
   bool NoReturn = getFunctionExtInfo(*calleeType).getNoReturn();
 
@@ -2439,6 +2437,13 @@
   bool OmitArguments = false;
 
   if (FunctionDecl *FD = C->getDirectCallee()) {
+// TODO: Support construction contexts for variadic function arguments.
+// These are a bit problematic and not very useful because passing
+// C++ objects as C-style variadic arguments doesn't work in general
+// (see [expr.call]).
+if (!FD->isVariadic())
+  findConstructionContextsForArguments(C);
+
 if (FD->isNoReturn() || C->isBuiltinAssumeFalse(*Context))
   NoReturn = true;
 if (FD->hasAttr())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340975 - [CFG] [analyzer] Disable argument construction contexts for variadic functions.

2018-08-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 29 14:50:52 2018
New Revision: 340975

URL: http://llvm.org/viewvc/llvm-project?rev=340975&view=rev
Log:
[CFG] [analyzer] Disable argument construction contexts for variadic functions.

The analyzer doesn't make use of them anyway and they seem to have
pretty weird AST from time to time, so let's just skip them for now.

Fixes pr37769.

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

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=340975&r1=340974&r2=340975&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Aug 29 14:50:52 2018
@@ -2421,8 +2421,6 @@ CFGBlock *CFGBuilder::VisitCallExpr(Call
 if (!boundType.isNull()) calleeType = boundType;
   }
 
-  findConstructionContextsForArguments(C);
-
   // If this is a call to a no-return function, this stops the block here.
   bool NoReturn = getFunctionExtInfo(*calleeType).getNoReturn();
 
@@ -2439,6 +2437,13 @@ CFGBlock *CFGBuilder::VisitCallExpr(Call
   bool OmitArguments = false;
 
   if (FunctionDecl *FD = C->getDirectCallee()) {
+// TODO: Support construction contexts for variadic function arguments.
+// These are a bit problematic and not very useful because passing
+// C++ objects as C-style variadic arguments doesn't work in general
+// (see [expr.call]).
+if (!FD->isVariadic())
+  findConstructionContextsForArguments(C);
+
 if (FD->isNoReturn() || C->isBuiltinAssumeFalse(*Context))
   NoReturn = true;
 if (FD->hasAttr())

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=340975&r1=340974&r2=340975&view=diff
==
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp Wed Aug 29 14:50:52 2018
@@ -1028,3 +1028,18 @@ void testOperators() {
   C(1) + C(2);
 }
 } // namespace operators
+
+namespace variadic_function_arguments {
+class C {
+ public:
+  C(int);
+};
+
+int variadic(...);
+
+// This code is quite exotic, so let's not test the CFG for it,
+// but only make sure we don't crash.
+void testCrashOnVariadicArgument() {
+  C c(variadic(0 ? c : 0)); // no-crash
+}
+} // namespace variadic_function_arguments


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


[PATCH] D51434: [HIP] Add -fvisibility hidden option to clang

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 163196.
yaxunl added a comment.

Revised by Artem's comments.


https://reviews.llvm.org/D51434

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-toolchain.hip


Index: test/Driver/hip-toolchain.hip
===
--- test/Driver/hip-toolchain.hip
+++ test/Driver/hip-toolchain.hip
@@ -15,13 +15,15 @@
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]]
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -247,6 +247,12 @@
   if (DriverArgs.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc,
  false))
 CC1Args.push_back("-fcuda-rdc");
+
+  // Default to "hidden" visibility, as object level linking will not be
+  // supported for the foreseeable future.
+  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
+ options::OPT_fvisibility_ms_compat))
+CC1Args.append({"-fvisibility", "hidden"});
 }
 
 llvm::opt::DerivedArgList *


Index: test/Driver/hip-toolchain.hip
===
--- test/Driver/hip-toolchain.hip
+++ test/Driver/hip-toolchain.hip
@@ -15,13 +15,15 @@
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]]
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -247,6 +247,12 @@
   if (DriverArgs.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc,
  false))
 CC1Args.push_back("-fcuda-rdc");
+
+  // Default to "hidden" visibility, as object level linking will not be
+  // supported for the foreseeable future.
+  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
+ options::OPT_fvisibility_ms_compat))
+CC1Args.append({"-fvisibility", "hidden"});
 }
 
 llvm::opt::DerivedArgList *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:3518
+the behavior of ``inline`` in both C99 inline semantics and C++ inline
+semantics).
+

Might be useful to be a bit more explicit about how it differs:

> [...] is just a hint. In particular, an out-of-line definition is still 
> emitted for a function with external linkage even if all call sites are 
> inlined, unlike in C99 inline semantics and C++ inline semantics.



Comment at: include/clang/Basic/AttrDocs.td:3524
+
+And in particular as special cases, ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version

Maybe replace the "And in particular as special cases," with "Some important 
consequences:"



Comment at: include/clang/Basic/AttrDocs.td:3536
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default.
+

I'd add: "It is unspecified which macro is defined in a C++ compilation."

(In practice, Clang always defines the GNU_INLINE macro, as do very old 
versions of GCC. More recent versions of GCC define GNU_INLINE in C++98 mode 
and STDC_INLINE in C++11 mode onwards, despite C++98 and C++11 having identical 
inline semantics. I don't think we want to give any guarantees about our 
behavior here.)


Repository:
  rC Clang

https://reviews.llvm.org/D51190



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


[PATCH] D51434: [HIP] Add -fvisibility hidden option to clang

2018-08-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:255
+ options::OPT_fvisibility_ms_compat)) {
+CC1Args.push_back("-fvisibility");
+CC1Args.push_back("hidden");

Nit: You could collapse multiple `push_back` calls into a single 
`append({...})`:
`CC1Args.append({"-fvisibility", "hidden"});`


https://reviews.llvm.org/D51434



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


[PATCH] D51329: [Attribute/Diagnostics] Print macro instead of whole attribute for address_space

2018-08-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

You also need to update the various other places that create `AttributedType`s 
(eg, template instantiation, ASTImporter, deserialization) to pass in the macro 
name.  You can try removing the default argument from 
`ASTContext::getAttributedType` to find other places that might need updating.




Comment at: include/clang/AST/Type.h:4318-4323
+  // If the attribute this type holds is address_space and this attribute was
+  // declared as part of a macro, we store the macro identifier information.
+  // This will be used for printing the macro name instead of
+  // `__attribute__((address_space(n)))` in diagnostics relating to differing
+  // address_spaces between types.
+  IdentifierInfo *AddressSpaceMacroII;

Please keep this general, there's nothing address-space-specific here.



Comment at: include/clang/AST/Type.h:4343-4344
   QualType getEquivalentType() const { return EquivalentType; }
+  IdentifierInfo *getAddressSpaceMacroII() const { return AddressSpaceMacroII; 
}
+  bool hasAddressSpaceMacroII() const { return AddressSpaceMacroII != nullptr; 
}
 

Likewise.



Comment at: include/clang/Sema/ParsedAttr.h:538-542
+  void setMacroII(IdentifierInfo *MacroName) { MacroII = MacroName; }
+
+  bool hasMacroII() const { return MacroII != nullptr; }
+
+  IdentifierInfo *getMacroII() const { return MacroII; }

Please use `MacroIdentifier` or `MacroName` in these function names; 
abbreviations such as `II` should only be used in entities with a relatively 
small scope, not in public member functions (here and in `AttributedType).

A documentation comment on these would also be useful.



Comment at: lib/AST/TypePrinter.cpp:1370
+
+// Remove the underlying address space so it won't be printed.
+SplitQualType SplitTy = T->getModifiedType().split();

leonardchan wrote:
> rsmith wrote:
> > leonardchan wrote:
> > > rsmith wrote:
> > > > This is unnecessary; just print the modified type here. (The modified 
> > > > type by definition does not have the attribute applied to it.)
> > > When you say the modified type, do you mean just the type without it's 
> > > qualifiers? I wasn't sure if removing all the qualifiers would suffice 
> > > since there were also other  non-address_space qualifiers that could be 
> > > printed.
> > I mean `T->getModifiedType()`, which tracks what the type was before the 
> > attribute was applied.
> Oh, I understand that you meant `T->getModifiedType()`. This is a special 
> case when printing the `address_space` since even though the attribute is 
> applied and printed here, when we reach the qualifiers of the modified type, 
> the address space will still be printed unless we remove it here.
> 
> I'm not sure if there's a better way to do this though.
If the address space qualifiers are present on the modified type, then that's a 
bug in the creation of the `AttributedType`. And indeed looking at r340765, I 
see we are passing the wrong type in as the modified type when creating the 
`AttributedType`. Please fix that, and then just use `getModifiedType` here.



Comment at: lib/Parse/ParseDecl.cpp:169-170
   assert(Tok.is(tok::kw___attribute) && "Not a GNU attribute list!");
+  unsigned OldNumAttrs = attrs.size();
+  Token AttrTok = Tok;
 

This is not right: the loop below parses multiple `__attribute__`s and you 
should track each one separately...



Comment at: lib/Parse/ParseDecl.cpp:173
   while (Tok.is(tok::kw___attribute)) {
 ConsumeToken();
 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,

... by grabbing the location of the `__attribute__` token here.



Comment at: lib/Parse/ParseDecl.cpp:244-252
+// If this was declared in a macro, attatch the macro IdentifierInfo to the
+// parsed attribute.
+for (const auto &MacroPair : PP.getAttributeMacros()) {
+  if (SourceLocInSourceRange(AttrTok.getLocation(), MacroPair.first,
+ PP.getSourceManager())) {
+ApplyMacroIIToParsedAttrs(attrs, NumParsedAttrs, MacroPair.second);
+break;

You shouldn't do this if `NumParsedAttrs != 1`. We're only looking for a macro 
that exactly covers one attribute.

(Also, your computation of the number of attributes in the attribute list is 
not correct in the presence of late-parsed attributes.)



Comment at: lib/Parse/ParseDecl.cpp:246-252
+for (const auto &MacroPair : PP.getAttributeMacros()) {
+  if (SourceLocInSourceRange(AttrTok.getLocation(), MacroPair.first,
+ PP.getSourceManager())) {
+ApplyMacroIIToParsedAttrs(attrs, NumParsedAttrs, MacroPair.second);
+break;
+  }
+}

From my earlier comment: "look through the source location information for the 
outerm

r340972 - [analyzer] Fix tests on 32-bit platforms by specifying the tuple explicitly

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 14:18:47 2018
New Revision: 340972

URL: http://llvm.org/viewvc/llvm-project?rev=340972&view=rev
Log:
[analyzer] Fix tests on 32-bit platforms by specifying the tuple explicitly

Modified:
cfe/trunk/test/Analysis/casts.c

Modified: cfe/trunk/test/Analysis/casts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=340972&r1=340971&r2=340972&view=diff
==
--- cfe/trunk/test/Analysis/casts.c (original)
+++ cfe/trunk/test/Analysis/casts.c Wed Aug 29 14:18:47 2018
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
 // RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -w %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -w %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -DBIT32=1 -w %s
 
 extern void clang_analyzer_eval(_Bool);
 
@@ -196,16 +197,19 @@ void testSwitchWithSizeofs() {
 
 #ifdef EAGERLY_ASSUME
 
-// expected-no-diagnostics
-
-int globalA; // TODO: the example is not representative.
+int globalA;
 extern int globalFunc();
 void no_crash_on_symsym_cast_to_long() {
   char c = globalFunc() - 5;
   c == 0;
   globalA -= c;
   globalA == 3;
-  (long)globalA << 48; // no-crash
+  (long)globalA << 48;
+  #ifdef BIT32
+  // expected-warning@-2{{The result of the left shift is undefined due to 
shifting by '48', which is greater or equal to the width of type 'long'}}
+  #else
+  // expected-no-diagnostics
+  #endif
 }
 
 #endif


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


[PATCH] D51393: Provide a method for generating deterministic IDs for pointers allocated in BumpPtrAllocator

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D51393#1217644, @aprantl wrote:

> Just for consideration: The raw pointers in dumps are sometimes useful while 
> in a debugger session, because you can cast a pointer and dump the object in 
> the debugger.


Yup, i use that as well from time to time, so i guess we can either dump both 
or make a flag.




Comment at: llvm/include/llvm/Support/Allocator.h:290
+  /// Returns an empty optional if the pointer is not found in the allocator.
+  llvm::Optional> identifyObject(const void *Ptr) {
+const char *P = reinterpret_cast(Ptr);

I'd much rather have the first element signed, because it's the only one that 
can actually carry "negative" values. Maybe just let's do two `int64_t`s or 
`intptr_t`s?



Comment at: llvm/include/llvm/Support/Allocator.h:295
+  if (P >= S && P < S + computeSlabSize(Idx))
+return std::make_pair(Idx, P - S);
+}

aprantl wrote:
> `return {Idx, P - S};`
And, well, let's make integral casts explicit here.


https://reviews.llvm.org/D51393



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


[PATCH] D51434: [HIP] Add -fvisibility hidden option to clang

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 163186.
yaxunl retitled this revision from "[HIP] Add -amdgpu-internalize-symbols 
option to opt" to "[HIP] Add -fvisibility hidden option to clang".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Use -fvisibility hidden.


https://reviews.llvm.org/D51434

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-toolchain.hip


Index: test/Driver/hip-toolchain.hip
===
--- test/Driver/hip-toolchain.hip
+++ test/Driver/hip-toolchain.hip
@@ -15,13 +15,15 @@
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]]
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -247,6 +247,14 @@
   if (DriverArgs.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc,
  false))
 CC1Args.push_back("-fcuda-rdc");
+
+  // Default to "hidden" visibility, as object level linking will not be
+  // supported for the foreseeable future.
+  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
+ options::OPT_fvisibility_ms_compat)) {
+CC1Args.push_back("-fvisibility");
+CC1Args.push_back("hidden");
+  }
 }
 
 llvm::opt::DerivedArgList *


Index: test/Driver/hip-toolchain.hip
===
--- test/Driver/hip-toolchain.hip
+++ test/Driver/hip-toolchain.hip
@@ -15,13 +15,15 @@
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" 
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[A_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
-// CHECK-SAME: "-fcuda-is-device" {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
+// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden"
+// CHECK-SAME: {{.*}} "-o" [[B_BC:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC]] [[B_BC]]
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -247,6 +247,14 @@
   if (DriverArgs.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc,
  false))
 CC1Args.push_back("-fcuda-rdc");
+
+  // Default to "hidden" visibility, as object level linking will not be
+  // supported for the foreseeable future.
+  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
+ options::OPT_fvisibility_ms_compat)) {
+CC1Args.push_back("-fvisibility");
+CC1Args.push_back("hidden");
+  }
 }
 
 llvm::opt::DerivedArgList *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-08-29 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 163185.
Szelethus added a comment.

Fixed two crashes. Interesting how many much better this approach works, as 
I've never encountered `FunctionType`d objects or only forward declared typed 
pointers after dereferencing.


https://reviews.llvm.org/D51057

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/objcpp-uninitialized-object.mm

Index: test/Analysis/objcpp-uninitialized-object.mm
===
--- test/Analysis/objcpp-uninitialized-object.mm
+++ test/Analysis/objcpp-uninitialized-object.mm
@@ -4,7 +4,7 @@
 
 struct StructWithBlock {
   int a;
-  myBlock z; // expected-note{{uninitialized pointer 'this->z'}}
+  myBlock z; // expected-note{{uninitialized field 'this->z'}}
 
   StructWithBlock() : a(0), z(^{}) {}
 
Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -46,6 +46,50 @@
 }
 
 //===--===//
+// Alloca tests.
+//===--===//
+
+struct UntypedAllocaTest {
+  void *allocaPtr;
+  int dontGetFilteredByNonPedanticMode = 0;
+
+  UntypedAllocaTest() : allocaPtr(__builtin_alloca(sizeof(int))) {
+// All good!
+  }
+};
+
+void fUntypedAllocaTest() {
+  UntypedAllocaTest();
+}
+
+struct TypedAllocaTest1 {
+  int *allocaPtr; // expected-note{{uninitialized pointee 'this->allocaPtr'}}
+  int dontGetFilteredByNonPedanticMode = 0;
+
+  TypedAllocaTest1() // expected-warning{{1 uninitialized field}}
+  : allocaPtr(static_cast(__builtin_alloca(sizeof(int {}
+};
+
+void fTypedAllocaTest1() {
+  TypedAllocaTest1();
+}
+
+struct TypedAllocaTest2 {
+  int *allocaPtr;
+  int dontGetFilteredByNonPedanticMode = 0;
+
+  TypedAllocaTest2()
+  : allocaPtr(static_cast(__builtin_alloca(sizeof(int {
+*allocaPtr = 5;
+// All good!
+  }
+};
+
+void fTypedAllocaTest2() {
+  TypedAllocaTest2();
+}
+
+//===--===//
 // Heap pointer tests.
 //===--===//
 
@@ -203,18 +247,14 @@
   CyclicPointerTest1();
 }
 
-// TODO: Currently, the checker ends up in an infinite loop for the following
-// test case.
-/*
 struct CyclicPointerTest2 {
-  int **pptr;
+  int **pptr; // no-crash
   CyclicPointerTest2() : pptr(reinterpret_cast(&pptr)) {}
 };
 
 void fCyclicPointerTest2() {
   CyclicPointerTest2();
 }
-*/
 
 //===--===//
 // Void pointer tests.
@@ -471,6 +511,39 @@
 }
 
 //===--===//
+// Incomplete pointee tests.
+//===--===//
+
+class IncompleteType;
+
+struct IncompletePointeeTypeTest {
+  IncompleteType *pImpl; //no-crash
+  int dontGetFilteredByNonPedanticMode = 0;
+
+  IncompletePointeeTypeTest(IncompleteType *A) : pImpl(A) {}
+};
+
+void fIncompletePointeeTypeTest(void *ptr) {
+  IncompletePointeeTypeTest(reinterpret_cast(ptr));
+}
+
+//===--===//
+// Function pointer tests.
+//===--===//
+
+struct FunctionPointerWithDifferentDynTypeTest {
+  using Func1 = void *(*)();
+  using Func2 = int *(*)();
+
+  Func1 f; // no-crash
+  FunctionPointerWithDifferentDynTypeTest(Func2 f) : f((Func1)f) {}
+};
+
+// Note that there isn't a function calling the constructor of
+// FunctionPointerWithDifferentDynTypeTest, because a crash could only be
+// reproduced without it.
+
+//===--===//
 // Member pointer tests.
 //===--===//
 
@@ -645,6 +718,15 @@
   CyclicList(&n1, int());
 }
 
+struct RingListTest {
+  RingListTest *next; // no-crash
+  RingListTest() : next(this) {}
+};
+
+void fRingListTest() {
+  RingListTest();
+}
+
 //===--===//
 // Tests for classes containing references.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ lib

LLVM buildmaster will be restarted tonight

2018-08-29 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM Pacific time today.

Thanks

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


[PATCH] D51209: AMDGPU: Default to hidden visibility

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D51209



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


r340968 - [OPENMP] Do not create offloading entry for declare target variables

2018-08-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 29 13:41:37 2018
New Revision: 340968

URL: http://llvm.org/viewvc/llvm-project?rev=340968&view=rev
Log:
[OPENMP] Do not create offloading entry for declare target variables
declarations.

We should not create offloading entries for declare target var
declarations as it causes compiler crash.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=340968&r1=340967&r2=340968&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Aug 29 13:41:37 2018
@@ -3989,6 +3989,9 @@ void CGOpenMPRuntime::createOffloadEntri
   CGM.getDiags().Report(DiagID);
   continue;
 }
+// The vaiable has no definition - no need to add the entry.
+if (CE->getVarSize().isZero())
+  continue;
 break;
   }
   case OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryLink:
@@ -8108,7 +8111,12 @@ void CGOpenMPRuntime::registerTargetGlob
 case OMPDeclareTargetDeclAttr::MT_To:
   Flags = OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryTo;
   VarName = CGM.getMangledName(VD);
-  VarSize = CGM.getContext().getTypeSizeInChars(VD->getType());
+  if (VD->hasDefinition(CGM.getContext()) != VarDecl::DeclarationOnly) {
+VarSize = CGM.getContext().getTypeSizeInChars(VD->getType());
+assert(!VarSize.isZero() && "Expected non-zero size of the variable");
+  } else {
+VarSize = CharUnits::Zero();
+  }
   Linkage = CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false);
   // Temp solution to prevent optimizations of the internal variables.
   if (CGM.getLangOpts().OpenMPIsDevice && !VD->isExternallyVisible()) {

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=340968&r1=340967&r2=340968&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Wed Aug 29 13:41:37 2018
@@ -143,4 +143,8 @@ int baz5() {
 // CHECK-DAG: declare extern_weak signext i32 @__create()
 
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
+
+// CHECK-DAG: !{i32 1, !"aaa", i32 0, i32 {{[0-9]+}}}
+// CHECK-DAG: !{i32 1, !"ccc", i32 0, i32 {{[0-9]+}}}
+
 #endif // HEADER


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


[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340967: Add predefined macro __gnu_linux__ for proper 
aux-triple (authored by yaxunl, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51441

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/predefined-macros.c


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -183,9 +183,11 @@
 // CHECK-HIP: #define __HIP__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device \
+// RUN:   -aux-triple x86_64-unknown-linux -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV
 // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV: #define __HIPCC__ 1
 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-DEV: #define __HIP__ 1
+// CHECK_HIP-DEV: #define __linux__ 1
+// CHECK_HIP-DEV: #define __gnu_linux__ 1
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1128,6 +1128,7 @@
   if (AuxTriple.getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__linux__");
+Builder.defineMacro("__gnu_linux__");
 // Used in features.h. If this is omitted, math.h doesn't declare float
 // versions of the functions in bits/mathcalls.h.
 if (LangOpts.CPlusPlus)


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -183,9 +183,11 @@
 // CHECK-HIP: #define __HIP__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device \
+// RUN:   -aux-triple x86_64-unknown-linux -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV
 // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV: #define __HIPCC__ 1
 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-DEV: #define __HIP__ 1
+// CHECK_HIP-DEV: #define __linux__ 1
+// CHECK_HIP-DEV: #define __gnu_linux__ 1
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1128,6 +1128,7 @@
   if (AuxTriple.getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__linux__");
+Builder.defineMacro("__gnu_linux__");
 // Used in features.h. If this is omitted, math.h doesn't declare float
 // versions of the functions in bits/mathcalls.h.
 if (LangOpts.CPlusPlus)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340967 - Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Aug 29 13:39:22 2018
New Revision: 340967

URL: http://llvm.org/viewvc/llvm-project?rev=340967&view=rev
Log:
Add predefined macro __gnu_linux__ for proper aux-triple

Clang predefine macro __linx__ for aux-triple with Linux OS
but does not predefine macro __gnu_linux__. This causes
some compilation error for certain applications, e.g. Eigen.

This patch fixes that.

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

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=340967&r1=340966&r2=340967&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Aug 29 13:39:22 2018
@@ -1128,6 +1128,7 @@ static void InitializePredefinedAuxMacro
   if (AuxTriple.getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__linux__");
+Builder.defineMacro("__gnu_linux__");
 // Used in features.h. If this is omitted, math.h doesn't declare float
 // versions of the functions in bits/mathcalls.h.
 if (LangOpts.CPlusPlus)

Modified: cfe/trunk/test/Preprocessor/predefined-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=340967&r1=340966&r2=340967&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-macros.c Wed Aug 29 13:39:22 2018
@@ -183,9 +183,11 @@
 // CHECK-HIP: #define __HIP__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device \
+// RUN:   -aux-triple x86_64-unknown-linux -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV
 // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV: #define __HIPCC__ 1
 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-DEV: #define __HIP__ 1
+// CHECK_HIP-DEV: #define __linux__ 1
+// CHECK_HIP-DEV: #define __gnu_linux__ 1


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


[PATCH] D51252: [analyzer] Resolve the crash in ReturnUndefChecker

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340965: [analyzer] Resolve the crash in ReturnUndefChecker 
(authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51252?vs=162536&id=163181#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51252

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/casts.c


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1201,6 +1201,7 @@
 
 const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
SVal V) {
+  V = simplifySVal(state, V);
   if (V.isUnknownOrUndef())
 return nullptr;
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -69,6 +69,7 @@
   ProgramStateRef State = C.getState();
   const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
   const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
+  assert(LHS && RHS && "Values unknown, inconsistent state");
   return (unsigned)RHS->getZExtValue() > LHS->countLeadingZeros();
 }
 
Index: cfe/trunk/test/Analysis/casts.c
===
--- cfe/trunk/test/Analysis/casts.c
+++ cfe/trunk/test/Analysis/casts.c
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -w %s
 
 extern void clang_analyzer_eval(_Bool);
 
@@ -16,6 +17,8 @@
 
 void getsockname();
 
+#ifndef EAGERLY_ASSUME
+
 void f(int sock) {
   struct sockaddr_storage storage;
   struct sockaddr* sockaddr = (struct sockaddr*)&storage; // 
expected-warning{{Casting data to a larger structure type and accessing a field 
can lead to memory access errors or data corruption}}
@@ -188,3 +191,21 @@
   case sizeof(char):; // no-crash
   }
 }
+
+#endif
+
+#ifdef EAGERLY_ASSUME
+
+// expected-no-diagnostics
+
+int globalA; // TODO: the example is not representative.
+extern int globalFunc();
+void no_crash_on_symsym_cast_to_long() {
+  char c = globalFunc() - 5;
+  c == 0;
+  globalA -= c;
+  globalA == 3;
+  (long)globalA << 48; // no-crash
+}
+
+#endif


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1201,6 +1201,7 @@
 
 const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
SVal V) {
+  V = simplifySVal(state, V);
   if (V.isUnknownOrUndef())
 return nullptr;
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -69,6 +69,7 @@
   ProgramStateRef State = C.getState();
   const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
   const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
+  assert(LHS && RHS && "Values unknown, inconsistent state");
   return (unsigned)RHS->getZExtValue() > LHS->countLeadingZeros();
 }
 
Index: cfe/trunk/test/Analysis/casts.c
===
--- cfe/trunk/test/Analysis/casts.c
+++ cfe/trunk/test/Analysis/casts.c
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -analyzer-config eagerly-assume=false -verify %s
-// RUN: %clang_analyze_cc1 -triple i386-a

[PATCH] D51252: [analyzer] Resolve the crash in ReturnUndefChecker

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340965: [analyzer] Resolve the crash in ReturnUndefChecker 
(authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51252?vs=162536&id=163180#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51252

Files:
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/casts.c


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1201,6 +1201,7 @@
 
 const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
SVal V) {
+  V = simplifySVal(state, V);
   if (V.isUnknownOrUndef())
 return nullptr;
 
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -69,6 +69,7 @@
   ProgramStateRef State = C.getState();
   const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
   const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
+  assert(LHS && RHS && "Values unknown, inconsistent state");
   return (unsigned)RHS->getZExtValue() > LHS->countLeadingZeros();
 }
 
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -w %s
 
 extern void clang_analyzer_eval(_Bool);
 
@@ -16,6 +17,8 @@
 
 void getsockname();
 
+#ifndef EAGERLY_ASSUME
+
 void f(int sock) {
   struct sockaddr_storage storage;
   struct sockaddr* sockaddr = (struct sockaddr*)&storage; // 
expected-warning{{Casting data to a larger structure type and accessing a field 
can lead to memory access errors or data corruption}}
@@ -188,3 +191,21 @@
   case sizeof(char):; // no-crash
   }
 }
+
+#endif
+
+#ifdef EAGERLY_ASSUME
+
+// expected-no-diagnostics
+
+int globalA; // TODO: the example is not representative.
+extern int globalFunc();
+void no_crash_on_symsym_cast_to_long() {
+  char c = globalFunc() - 5;
+  c == 0;
+  globalA -= c;
+  globalA == 3;
+  (long)globalA << 48; // no-crash
+}
+
+#endif


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1201,6 +1201,7 @@
 
 const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
SVal V) {
+  V = simplifySVal(state, V);
   if (V.isUnknownOrUndef())
 return nullptr;
 
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -69,6 +69,7 @@
   ProgramStateRef State = C.getState();
   const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
   const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
+  assert(LHS && RHS && "Values unknown, inconsistent state");
   return (unsigned)RHS->getZExtValue() > LHS->countLeadingZeros();
 }
 
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -analyzer-config eagerly-assume=false -verify %s
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -analyzer-config eagerly-assume=false -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-che

[PATCH] D51251: [analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by default

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340963: [analyzer] Move analyzer-eagerly-assume to 
AnalyzerOptions, enable by default (authored by george.karpenkov, committed by 
).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51251?vs=162534&id=163178#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51251

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/MisusedMovedObject.cpp
  cfe/trunk/test/Analysis/PR24184.cpp
  cfe/trunk/test/Analysis/PR37855.c
  cfe/trunk/test/Analysis/additive-folding-range-constraints.c
  cfe/trunk/test/Analysis/additive-folding.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/analyzer-config.cpp
  cfe/trunk/test/Analysis/array-struct-region.c
  cfe/trunk/test/Analysis/atomics.c
  cfe/trunk/test/Analysis/blocks-no-inline.c
  cfe/trunk/test/Analysis/bstring.c
  cfe/trunk/test/Analysis/bstring.cpp
  cfe/trunk/test/Analysis/call-invalidation.cpp
  cfe/trunk/test/Analysis/casts.c
  cfe/trunk/test/Analysis/conditional-operator.cpp
  cfe/trunk/test/Analysis/const-method-call.cpp
  cfe/trunk/test/Analysis/constant-folding.c
  cfe/trunk/test/Analysis/copy-elision.cpp
  cfe/trunk/test/Analysis/ctor.mm
  cfe/trunk/test/Analysis/cxx-for-range.cpp
  cfe/trunk/test/Analysis/dtor.cpp
  cfe/trunk/test/Analysis/edges-new.mm
  cfe/trunk/test/Analysis/func.c
  cfe/trunk/test/Analysis/global-region-invalidation.c
  cfe/trunk/test/Analysis/global_region_invalidation.mm
  cfe/trunk/test/Analysis/gtest.cpp
  cfe/trunk/test/Analysis/inline-plist.c
  cfe/trunk/test/Analysis/inline.cpp
  cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m
  cfe/trunk/test/Analysis/inlining/containers.cpp
  cfe/trunk/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
  cfe/trunk/test/Analysis/inlining/false-positive-suppression.c
  cfe/trunk/test/Analysis/inlining/stl.cpp
  cfe/trunk/test/Analysis/invalidated-iterator.cpp
  cfe/trunk/test/Analysis/iterator-range.cpp
  cfe/trunk/test/Analysis/ivars.m
  cfe/trunk/test/Analysis/lifetime-extension.cpp
  cfe/trunk/test/Analysis/logical-ops.c
  cfe/trunk/test/Analysis/loop-widening-notes.cpp
  cfe/trunk/test/Analysis/loop-widening.c
  cfe/trunk/test/Analysis/malloc-plist.c
  cfe/trunk/test/Analysis/misc-ps-eager-assume.m
  cfe/trunk/test/Analysis/misc-ps.c
  cfe/trunk/test/Analysis/missing-bind-temporary.cpp
  cfe/trunk/test/Analysis/new-ctor-conservative.cpp
  cfe/trunk/test/Analysis/new-ctor-inlined.cpp
  cfe/trunk/test/Analysis/new-ctor-recursive.cpp
  cfe/trunk/test/Analysis/new-ctor-symbolic.cpp
  cfe/trunk/test/Analysis/new.cpp
  cfe/trunk/test/Analysis/null-deref-path-notes.cpp
  cfe/trunk/test/Analysis/objc-for.m
  cfe/trunk/test/Analysis/plist-macros.cpp
  cfe/trunk/test/Analysis/plist-output.m
  cfe/trunk/test/Analysis/pr22954.c
  cfe/trunk/test/Analysis/properties.m
  cfe/trunk/test/Analysis/ptr-arith.c
  cfe/trunk/test/Analysis/reference.cpp
  cfe/trunk/test/Analysis/region-store.c
  cfe/trunk/test/Analysis/self-assign.cpp
  cfe/trunk/test/Analysis/std-c-library-functions.c
  cfe/trunk/test/Analysis/string.c
  cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c
  cfe/trunk/test/Analysis/switch-case.c
  cfe/trunk/test/Analysis/temp-obj-dtors-option.cpp
  cfe/trunk/test/Analysis/templates.cpp
  cfe/trunk/test/Analysis/temporaries.cpp
  cfe/trunk/test/Analysis/test-after-div-zero.c
  cfe/trunk/test/Analysis/unions.cpp
  cfe/trunk/test/Analysis/unix-fns.c
  cfe/trunk/test/Analysis/weak-functions.c

Index: cfe/trunk/test/Analysis/new.cpp
===
--- cfe/trunk/test/Analysis/new.cpp
+++ cfe/trunk/test/Analysis/new.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify -analyzer-config eagerly-assume=false %s
 #include "Inputs/system-header-simulator-cxx.h"
 
 void clang_analyzer_eval(bool);
Index: cfe/trunk/test/Analysis/constant-folding.c
===
--- cfe/trunk/test/Analysis/constant-folding.c
+++ cfe/trunk/test/Analysis/constant-folding.c
@@ -1,4 +1,4 @@
-// RUN: %clang_

[PATCH] D51251: [analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by default

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340963: [analyzer] Move analyzer-eagerly-assume to 
AnalyzerOptions, enable by default (authored by george.karpenkov, committed by 
).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51251?vs=162534&id=163177#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51251

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/MisusedMovedObject.cpp
  test/Analysis/PR24184.cpp
  test/Analysis/PR37855.c
  test/Analysis/additive-folding-range-constraints.c
  test/Analysis/additive-folding.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/array-struct-region.c
  test/Analysis/atomics.c
  test/Analysis/blocks-no-inline.c
  test/Analysis/bstring.c
  test/Analysis/bstring.cpp
  test/Analysis/call-invalidation.cpp
  test/Analysis/casts.c
  test/Analysis/conditional-operator.cpp
  test/Analysis/const-method-call.cpp
  test/Analysis/constant-folding.c
  test/Analysis/copy-elision.cpp
  test/Analysis/ctor.mm
  test/Analysis/cxx-for-range.cpp
  test/Analysis/dtor.cpp
  test/Analysis/edges-new.mm
  test/Analysis/func.c
  test/Analysis/global-region-invalidation.c
  test/Analysis/global_region_invalidation.mm
  test/Analysis/gtest.cpp
  test/Analysis/inline-plist.c
  test/Analysis/inline.cpp
  test/Analysis/inlining/InlineObjCClassMethod.m
  test/Analysis/inlining/containers.cpp
  test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
  test/Analysis/inlining/false-positive-suppression.c
  test/Analysis/inlining/stl.cpp
  test/Analysis/invalidated-iterator.cpp
  test/Analysis/iterator-range.cpp
  test/Analysis/ivars.m
  test/Analysis/lifetime-extension.cpp
  test/Analysis/logical-ops.c
  test/Analysis/loop-widening-notes.cpp
  test/Analysis/loop-widening.c
  test/Analysis/malloc-plist.c
  test/Analysis/misc-ps-eager-assume.m
  test/Analysis/misc-ps.c
  test/Analysis/missing-bind-temporary.cpp
  test/Analysis/new-ctor-conservative.cpp
  test/Analysis/new-ctor-inlined.cpp
  test/Analysis/new-ctor-recursive.cpp
  test/Analysis/new-ctor-symbolic.cpp
  test/Analysis/new.cpp
  test/Analysis/null-deref-path-notes.cpp
  test/Analysis/objc-for.m
  test/Analysis/plist-macros.cpp
  test/Analysis/plist-output.m
  test/Analysis/pr22954.c
  test/Analysis/properties.m
  test/Analysis/ptr-arith.c
  test/Analysis/reference.cpp
  test/Analysis/region-store.c
  test/Analysis/self-assign.cpp
  test/Analysis/std-c-library-functions.c
  test/Analysis/string.c
  test/Analysis/svalbuilder-rearrange-comparisons.c
  test/Analysis/switch-case.c
  test/Analysis/temp-obj-dtors-option.cpp
  test/Analysis/templates.cpp
  test/Analysis/temporaries.cpp
  test/Analysis/test-after-div-zero.c
  test/Analysis/unions.cpp
  test/Analysis/unix-fns.c
  test/Analysis/weak-functions.c

Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -76,8 +76,6 @@
 def analyze_function : Separate<["-"], "analyze-function">,
   HelpText<"Run analysis on specific function (for C++ include parameters in name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias;
-def analyzer_eagerly_assume : Flag<["-"], "analyzer-eagerly-assume">,
-  HelpText<"Eagerly assume the truth/falseness of some symbolic constraints">;
 def trim_egraph : Flag<["-"], "trim-egraph">,
   HelpText<"Only show error-related paths in the analysis graph">;
 def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -1,8 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DSUPPRESS_OUT_OF_BOUND -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring.BufferOverlap,alpha.unix.cstring.NotNullTerminated,debug.ExprInspection -analyzer-store=region -Wno-null-dereferen

r340965 - [analyzer] Resolve the crash in ReturnUndefChecker

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:29:59 2018
New Revision: 340965

URL: http://llvm.org/viewvc/llvm-project?rev=340965&view=rev
Log:
[analyzer] Resolve the crash in ReturnUndefChecker

By making sure the returned value from getKnownSVal is consistent with
the value used inside expression engine.

PR38427

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/casts.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp?rev=340965&r1=340964&r2=340965&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp Wed Aug 29 
13:29:59 2018
@@ -69,6 +69,7 @@ static bool isLeftShiftResultUnrepresent
   ProgramStateRef State = C.getState();
   const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
   const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
+  assert(LHS && RHS && "Values unknown, inconsistent state");
   return (unsigned)RHS->getZExtValue() > LHS->countLeadingZeros();
 }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=340965&r1=340964&r2=340965&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Wed Aug 29 13:29:59 
2018
@@ -1201,6 +1201,7 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
 
 const llvm::APSInt *SimpleSValBuilder::getKnownValue(ProgramStateRef state,
SVal V) {
+  V = simplifySVal(state, V);
   if (V.isUnknownOrUndef())
 return nullptr;
 

Modified: cfe/trunk/test/Analysis/casts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=340965&r1=340964&r2=340965&view=diff
==
--- cfe/trunk/test/Analysis/casts.c (original)
+++ cfe/trunk/test/Analysis/casts.c Wed Aug 29 13:29:59 2018
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-analyzer-config eagerly-assume=false -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify 
-DEAGERLY_ASSUME=1 -w %s
 
 extern void clang_analyzer_eval(_Bool);
 
@@ -16,6 +17,8 @@ struct sockaddr_storage {};
 
 void getsockname();
 
+#ifndef EAGERLY_ASSUME
+
 void f(int sock) {
   struct sockaddr_storage storage;
   struct sockaddr* sockaddr = (struct sockaddr*)&storage; // 
expected-warning{{Casting data to a larger structure type and accessing a field 
can lead to memory access errors or data corruption}}
@@ -188,3 +191,21 @@ void testSwitchWithSizeofs() {
   case sizeof(char):; // no-crash
   }
 }
+
+#endif
+
+#ifdef EAGERLY_ASSUME
+
+// expected-no-diagnostics
+
+int globalA; // TODO: the example is not representative.
+extern int globalFunc();
+void no_crash_on_symsym_cast_to_long() {
+  char c = globalFunc() - 5;
+  c == 0;
+  globalA -= c;
+  globalA == 3;
+  (long)globalA << 48; // no-crash
+}
+
+#endif


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


[PATCH] D51250: [analyzer] [NFC] Remove unused argument from makeSymExprValNN

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340962: [analyzer] [NFC] Remove unused "state" 
argument from makeSymExprValNN (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51250?vs=162533&id=163176#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51250

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -534,7 +534,7 @@
   while (1) {
 switch (lhs.getSubKind()) {
 default:
-  return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+  return makeSymExprValNN(op, lhs, rhs, resultTy);
 case nonloc::PointerToMemberKind: {
   assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
  "Both SVals should have pointer-to-member-type");
@@ -582,7 +582,7 @@
   return makeTruthVal(true, resultTy);
 default:
   // This case also handles pointer arithmetic.
-  return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+  return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
   }
 }
@@ -643,9 +643,9 @@
 // 0<>a
 if (LHSValue == 0)
   return evalCastFromNonLoc(lhs, resultTy);
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   default:
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
 }
 case nonloc::SymbolValKind: {
@@ -757,7 +757,7 @@
 return *V;
 
   // Give up -- this is not a symbolic expression we can handle.
-  return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+  return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
 }
 }
   }
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -375,8 +375,7 @@
   }
 }
 
-SVal SValBuilder::makeSymExprValNN(ProgramStateRef State,
-   BinaryOperator::Opcode Op,
+SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
NonLoc LHS, NonLoc RHS,
QualType ResultTy) {
   const SymExpr *symLHS = LHS.getAsSymExpr();
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -139,8 +139,8 @@
   virtual SVal simplifySVal(ProgramStateRef State, SVal Val) = 0;
 
   /// Constructs a symbolic expression for two non-location values.
-  SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op,
-  NonLoc lhs, NonLoc rhs, QualType resultTy);
+  SVal makeSymExprValNN(BinaryOperator::Opcode op,
+NonLoc lhs, NonLoc rhs, QualType resultTy);
 
   SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op,
  SVal lhs, SVal rhs, QualType type);


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -534,7 +534,7 @@
   while (1) {
 switch (lhs.getSubKind()) {
 default:
-  return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+  return makeSymExprValNN(op, lhs, rhs, resultTy);
 case nonloc::PointerToMemberKind: {
   assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
  "Both SVals should have pointer-to-member-type");
@@ -582,7 +582,7 @@
   return makeTruthVal(true, resultTy);
 default:
   // This case also handles pointer arithmetic.
-  return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+  return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
   }
 }
@@ -643,9 +643,9 @@
 // 0<>a
 if (LHSValue == 0)
   return evalCastFromNonLoc(lhs, resultTy);
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   default:
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
 

r340964 - [analyzer] [NFC] Move class definition out of the function

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:29:39 2018
New Revision: 340964

URL: http://llvm.org/viewvc/llvm-project?rev=340964&view=rev
Log:
[analyzer] [NFC] Move class definition out of the function

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=340964&r1=340963&r2=340964&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Wed Aug 29 
13:29:39 2018
@@ -196,6 +196,45 @@ bool CallAndMessageChecker::uninitRefOrP
   return false;
 }
 
+class FindUninitializedField {
+public:
+  SmallVector FieldChain;
+
+private:
+  StoreManager &StoreMgr;
+  MemRegionManager &MrMgr;
+  Store store;
+
+public:
+  FindUninitializedField(StoreManager &storeMgr, MemRegionManager &mrMgr,
+ Store s)
+  : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
+
+  bool Find(const TypedValueRegion *R) {
+QualType T = R->getValueType();
+if (const RecordType *RT = T->getAsStructureType()) {
+  const RecordDecl *RD = RT->getDecl()->getDefinition();
+  assert(RD && "Referred record has no definition");
+  for (const auto *I : RD->fields()) {
+const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
+FieldChain.push_back(I);
+T = I->getType();
+if (T->getAsStructureType()) {
+  if (Find(FR))
+return true;
+} else {
+  const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
+  if (V.isUndef())
+return true;
+}
+FieldChain.pop_back();
+  }
+}
+
+return false;
+  }
+};
+
 bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
SVal V,
SourceRange ArgRange,
@@ -232,47 +271,7 @@ bool CallAndMessageChecker::PreVisitProc
   if (!CheckUninitFields)
 return false;
 
-  if (Optional LV =
-  V.getAs()) {
-
-class FindUninitializedField {
-public:
-  SmallVector FieldChain;
-private:
-  StoreManager &StoreMgr;
-  MemRegionManager &MrMgr;
-  Store store;
-public:
-  FindUninitializedField(StoreManager &storeMgr,
- MemRegionManager &mrMgr, Store s)
-  : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
-
-  bool Find(const TypedValueRegion *R) {
-QualType T = R->getValueType();
-if (const RecordType *RT = T->getAsStructureType()) {
-  const RecordDecl *RD = RT->getDecl()->getDefinition();
-  assert(RD && "Referred record has no definition");
-  for (const auto *I : RD->fields()) {
-const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
-FieldChain.push_back(I);
-T = I->getType();
-if (T->getAsStructureType()) {
-  if (Find(FR))
-return true;
-}
-else {
-  const SVal &V = StoreMgr.getBinding(store, 
loc::MemRegionVal(FR));
-  if (V.isUndef())
-return true;
-}
-FieldChain.pop_back();
-  }
-}
-
-return false;
-  }
-};
-
+  if (auto LV = V.getAs()) {
 const LazyCompoundValData *D = LV->getCVData();
 FindUninitializedField F(C.getState()->getStateManager().getStoreManager(),
  C.getSValBuilder().getRegionManager(),


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


r340963 - [analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by default

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:29:17 2018
New Revision: 340963

URL: http://llvm.org/viewvc/llvm-project?rev=340963&view=rev
Log:
[analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by default

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/MisusedMovedObject.cpp
cfe/trunk/test/Analysis/PR24184.cpp
cfe/trunk/test/Analysis/PR37855.c
cfe/trunk/test/Analysis/additive-folding-range-constraints.c
cfe/trunk/test/Analysis/additive-folding.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp
cfe/trunk/test/Analysis/array-struct-region.c
cfe/trunk/test/Analysis/atomics.c
cfe/trunk/test/Analysis/blocks-no-inline.c
cfe/trunk/test/Analysis/bstring.c
cfe/trunk/test/Analysis/bstring.cpp
cfe/trunk/test/Analysis/call-invalidation.cpp
cfe/trunk/test/Analysis/casts.c
cfe/trunk/test/Analysis/conditional-operator.cpp
cfe/trunk/test/Analysis/const-method-call.cpp
cfe/trunk/test/Analysis/constant-folding.c
cfe/trunk/test/Analysis/copy-elision.cpp
cfe/trunk/test/Analysis/ctor.mm
cfe/trunk/test/Analysis/cxx-for-range.cpp
cfe/trunk/test/Analysis/dtor.cpp
cfe/trunk/test/Analysis/edges-new.mm
cfe/trunk/test/Analysis/func.c
cfe/trunk/test/Analysis/global-region-invalidation.c
cfe/trunk/test/Analysis/global_region_invalidation.mm
cfe/trunk/test/Analysis/gtest.cpp
cfe/trunk/test/Analysis/inline-plist.c
cfe/trunk/test/Analysis/inline.cpp
cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m
cfe/trunk/test/Analysis/inlining/containers.cpp
cfe/trunk/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
cfe/trunk/test/Analysis/inlining/false-positive-suppression.c
cfe/trunk/test/Analysis/inlining/stl.cpp
cfe/trunk/test/Analysis/invalidated-iterator.cpp
cfe/trunk/test/Analysis/iterator-range.cpp
cfe/trunk/test/Analysis/ivars.m
cfe/trunk/test/Analysis/lifetime-extension.cpp
cfe/trunk/test/Analysis/logical-ops.c
cfe/trunk/test/Analysis/loop-widening-notes.cpp
cfe/trunk/test/Analysis/loop-widening.c
cfe/trunk/test/Analysis/malloc-plist.c
cfe/trunk/test/Analysis/misc-ps-eager-assume.m
cfe/trunk/test/Analysis/misc-ps.c
cfe/trunk/test/Analysis/missing-bind-temporary.cpp
cfe/trunk/test/Analysis/new-ctor-conservative.cpp
cfe/trunk/test/Analysis/new-ctor-inlined.cpp
cfe/trunk/test/Analysis/new-ctor-recursive.cpp
cfe/trunk/test/Analysis/new-ctor-symbolic.cpp
cfe/trunk/test/Analysis/new.cpp
cfe/trunk/test/Analysis/null-deref-path-notes.cpp
cfe/trunk/test/Analysis/objc-for.m
cfe/trunk/test/Analysis/plist-macros.cpp
cfe/trunk/test/Analysis/plist-output.m
cfe/trunk/test/Analysis/pr22954.c
cfe/trunk/test/Analysis/properties.m
cfe/trunk/test/Analysis/ptr-arith.c
cfe/trunk/test/Analysis/reference.cpp
cfe/trunk/test/Analysis/region-store.c
cfe/trunk/test/Analysis/self-assign.cpp
cfe/trunk/test/Analysis/std-c-library-functions.c
cfe/trunk/test/Analysis/string.c
cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c
cfe/trunk/test/Analysis/switch-case.c
cfe/trunk/test/Analysis/temp-obj-dtors-option.cpp
cfe/trunk/test/Analysis/templates.cpp
cfe/trunk/test/Analysis/temporaries.cpp
cfe/trunk/test/Analysis/test-after-div-zero.c
cfe/trunk/test/Analysis/unions.cpp
cfe/trunk/test/Analysis/unix-fns.c
cfe/trunk/test/Analysis/weak-functions.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=340963&r1=340962&r2=340963&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Aug 29 13:29:17 2018
@@ -76,8 +76,6 @@ def analyzer_display_progress : Flag<["-
 def analyze_function : Separate<["-"], "analyze-function">,
   HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, 
Alias;
-def analyzer_eagerly_assume : Flag<["-"], "analyzer-eagerly-assume">,
-  HelpText<"Eagerly assume the truth/falseness of some symbolic constraints">;
 def trim_egraph : Flag<["-"], "trim-egraph">,
   HelpText<"Only show error-related paths in the analysis graph">;
 def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/

r340962 - [analyzer] [NFC] Remove unused "state" argument from makeSymExprValNN

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:28:54 2018
New Revision: 340962

URL: http://llvm.org/viewvc/llvm-project?rev=340962&view=rev
Log:
[analyzer] [NFC] Remove unused "state" argument from makeSymExprValNN

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=340962&r1=340961&r2=340962&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Wed 
Aug 29 13:28:54 2018
@@ -139,8 +139,8 @@ public:
   virtual SVal simplifySVal(ProgramStateRef State, SVal Val) = 0;
 
   /// Constructs a symbolic expression for two non-location values.
-  SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op,
-  NonLoc lhs, NonLoc rhs, QualType resultTy);
+  SVal makeSymExprValNN(BinaryOperator::Opcode op,
+NonLoc lhs, NonLoc rhs, QualType resultTy);
 
   SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op,
  SVal lhs, SVal rhs, QualType type);

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=340962&r1=340961&r2=340962&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Wed Aug 29 13:28:54 2018
@@ -375,8 +375,7 @@ Optional SValBuilder::getConstantV
   }
 }
 
-SVal SValBuilder::makeSymExprValNN(ProgramStateRef State,
-   BinaryOperator::Opcode Op,
+SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op,
NonLoc LHS, NonLoc RHS,
QualType ResultTy) {
   const SymExpr *symLHS = LHS.getAsSymExpr();

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=340962&r1=340961&r2=340962&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Wed Aug 29 13:28:54 
2018
@@ -534,7 +534,7 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   while (1) {
 switch (lhs.getSubKind()) {
 default:
-  return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+  return makeSymExprValNN(op, lhs, rhs, resultTy);
 case nonloc::PointerToMemberKind: {
   assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
  "Both SVals should have pointer-to-member-type");
@@ -582,7 +582,7 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   return makeTruthVal(true, resultTy);
 default:
   // This case also handles pointer arithmetic.
-  return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+  return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
   }
 }
@@ -643,9 +643,9 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
 // 0<>a
 if (LHSValue == 0)
   return evalCastFromNonLoc(lhs, resultTy);
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   default:
-return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
   }
 }
 case nonloc::SymbolValKind: {
@@ -757,7 +757,7 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
 return *V;
 
   // Give up -- this is not a symbolic expression we can handle.
-  return makeSymExprValNN(state, op, InputLHS, InputRHS, resultTy);
+  return makeSymExprValNN(op, InputLHS, InputRHS, resultTy);
 }
 }
   }


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


r340961 - [analyzer] Better retain count rules for OSObjects

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:28:33 2018
New Revision: 340961

URL: http://llvm.org/viewvc/llvm-project?rev=340961&view=rev
Log:
[analyzer] Better retain count rules for OSObjects

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=340961&r1=340960&r2=340961&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Wed Aug 29 13:28:33 2018
@@ -31,6 +31,7 @@ const RefVal *getRefBinding(ProgramState
 
 ProgramStateRef setRefBinding(ProgramStateRef State, SymbolRef Sym,
  RefVal Val) {
+  assert(Sym != nullptr);
   return State->set(Sym, Val);
 }
 
@@ -418,17 +419,19 @@ void RetainCountChecker::processSummaryO
   }
 
   // Consult the summary for the return value.
-  SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol();
   RetEffect RE = Summ.getRetEffect();
-  if (const auto *MCall = dyn_cast(&CallOrMsg)) {
-if (Optional updatedRefVal =
-refValFromRetEffect(RE, MCall->getResultType())) {
-  state = setRefBinding(state, Sym, *updatedRefVal);
+
+  if (SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol()) {
+if (const auto *MCall = dyn_cast(&CallOrMsg)) {
+  if (Optional updatedRefVal =
+  refValFromRetEffect(RE, MCall->getResultType())) {
+state = setRefBinding(state, Sym, *updatedRefVal);
+  }
 }
-  }
 
-  if (RE.getKind() == RetEffect::NoRetHard && Sym)
-state = removeRefBinding(state, Sym);
+if (RE.getKind() == RetEffect::NoRetHard)
+  state = removeRefBinding(state, Sym);
+  }
 
   C.addTransition(state);
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=340961&r1=340960&r2=340961&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Wed Aug 29 
13:28:33 2018
@@ -19,6 +19,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang;
 using namespace ento;
@@ -53,29 +54,19 @@ RetainSummaryManager::getPersistentSumma
   return Summ;
 }
 
-static bool isOSObjectSubclass(QualType T);
-
-static bool isOSObjectSubclass(const CXXRecordDecl *RD) {
-  if (RD->getDeclName().getAsString() == "OSObject")
-return true;
-
-  const CXXRecordDecl *RDD = RD->getDefinition();
-  if (!RDD)
-return false;
+static bool isSubclass(const Decl *D,
+   StringRef ClassName) {
+  using namespace ast_matchers;
+  DeclarationMatcher SubclassM = cxxRecordDecl(isSameOrDerivedFrom(ClassName));
+  return !(match(SubclassM, *D, D->getASTContext()).empty());
+}
 
-  for (const CXXBaseSpecifier Spec : RDD->bases()) {
-if (isOSObjectSubclass(Spec.getType()))
-  return true;
-  }
-  return false;
+static bool isOSObjectSubclass(const Decl *D) {
+  return isSubclass(D, "OSObject");
 }
 
-/// \return Whether type represents an OSObject successor.
-static bool isOSObjectSubclass(QualType T) {
-  if (const auto *RD = T->getAsCXXRecordDecl()) {
-return isOSObjectSubclass(RD);
-  }
-  return false;
+static bool isOSIteratorSubclass(const Decl *D) {
+  return isSubclass(D, "OSIterator");
 }
 
 static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation) {
@@ -221,15 +212,22 @@ RetainSummaryManager::generateSummary(co
   }
 
   if (RetTy->isPointerType()) {
-if (TrackOSObjects && isOSObjectSubclass(RetTy->getPointeeType())) {
+
+const CXXRecordDecl *PD = RetTy->getPointeeType()->getAsCXXRecordDecl();
+if (TrackOSObjects && PD && isOSObjectSubclass(PD)) {
   if (const IdentifierInfo *II = FD->getIdentifier()) {
-StringRef FuncName = II->getName();
-if (FuncName.contains_lower("with")
-|| FuncName.contains_lower("create")
-|| FuncName.contains_lower("copy"))
+
+// All objects returned with functions starting with "get" are getters.
+if (II->getName().startswith("get")) {
+
+  // ...except for iterators.
+  if (isOSIteratorSubclass(PD))
+return getOSSummaryCreateRule(FD);
+  return getOSSummaryGetRule(FD);
+} else {
   return getOSSummaryCreateRule(FD);
+}
   }

r340960 - [analyzer] [NFC] Follow the convention when naming classes

2018-08-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Aug 29 13:28:13 2018
New Revision: 340960

URL: http://llvm.org/viewvc/llvm-project?rev=340960&view=rev
Log:
[analyzer] [NFC] Follow the convention when naming classes

Renames InvalidateRegionsWorker and RemoveDeadBindingsWorker

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=340960&r1=340959&r2=340960&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed Aug 29 13:28:13 2018
@@ -309,7 +309,7 @@ public:
 
//===--===//
 
 namespace {
-class invalidateRegionsWorker;
+class InvalidateRegionsWorker;
 
 class RegionStoreManager : public StoreManager {
 public:
@@ -336,7 +336,7 @@ private:
 
   /// A helper used to populate the work list with the given set of
   /// regions.
-  void populateWorkList(invalidateRegionsWorker &W,
+  void populateWorkList(InvalidateRegionsWorker &W,
 ArrayRef Values,
 InvalidatedRegions *TopLevelRegions);
 
@@ -946,7 +946,7 @@ RegionStoreManager::removeSubRegionBindi
 }
 
 namespace {
-class invalidateRegionsWorker : public ClusterAnalysis
+class InvalidateRegionsWorker : public ClusterAnalysis
 {
   const Expr *Ex;
   unsigned Count;
@@ -956,7 +956,7 @@ class invalidateRegionsWorker : public C
   StoreManager::InvalidatedRegions *Regions;
   GlobalsFilterKind GlobalsFilter;
 public:
-  invalidateRegionsWorker(RegionStoreManager &rm,
+  InvalidateRegionsWorker(RegionStoreManager &rm,
   ProgramStateManager &stateMgr,
   RegionBindingsRef b,
   const Expr *ex, unsigned count,
@@ -965,7 +965,7 @@ public:
   RegionAndSymbolInvalidationTraits &ITraitsIn,
   StoreManager::InvalidatedRegions *r,
   GlobalsFilterKind GFK)
- : ClusterAnalysis(rm, stateMgr, b),
+ : ClusterAnalysis(rm, stateMgr, b),
Ex(ex), Count(count), LCtx(lctx), IS(is), ITraits(ITraitsIn), 
Regions(r),
GlobalsFilter(GFK) {}
 
@@ -986,14 +986,14 @@ public:
 };
 }
 
-bool invalidateRegionsWorker::AddToWorkList(const MemRegion *R) {
+bool InvalidateRegionsWorker::AddToWorkList(const MemRegion *R) {
   bool doNotInvalidateSuperRegion = ITraits.hasTrait(
   R, RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
   const MemRegion *BaseR = doNotInvalidateSuperRegion ? R : R->getBaseRegion();
   return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
 }
 
-void invalidateRegionsWorker::VisitBinding(SVal V) {
+void InvalidateRegionsWorker::VisitBinding(SVal V) {
   // A symbol?  Mark it touched by the invalidation.
   if (SymbolRef Sym = V.getAsSymbol())
 IS.insert(Sym);
@@ -1018,7 +1018,7 @@ void invalidateRegionsWorker::VisitBindi
   }
 }
 
-void invalidateRegionsWorker::VisitCluster(const MemRegion *baseR,
+void InvalidateRegionsWorker::VisitCluster(const MemRegion *baseR,
const ClusterBindings *C) {
 
   bool PreserveRegionsContents =
@@ -1208,7 +1208,7 @@ void invalidateRegionsWorker::VisitClust
   B = B.addBinding(baseR, BindingKey::Direct, V);
 }
 
-bool invalidateRegionsWorker::isInitiallyIncludedGlobalRegion(
+bool InvalidateRegionsWorker::isInitiallyIncludedGlobalRegion(
 const MemRegion *R) {
   switch (GlobalsFilter) {
   case GFK_None:
@@ -1222,7 +1222,7 @@ bool invalidateRegionsWorker::isInitiall
   llvm_unreachable("unknown globals filter");
 }
 
-bool invalidateRegionsWorker::includeEntireMemorySpace(const MemRegion *Base) {
+bool InvalidateRegionsWorker::includeEntireMemorySpace(const MemRegion *Base) {
   if (isInitiallyIncludedGlobalRegion(Base))
 return true;
 
@@ -1256,7 +1256,7 @@ RegionStoreManager::invalidateGlobalRegi
   return B;
 }
 
-void RegionStoreManager::populateWorkList(invalidateRegionsWorker &W,
+void RegionStoreManager::populateWorkList(InvalidateRegionsWorker &W,
   ArrayRef Values,
   InvalidatedRegions *TopLevelRegions) 
{
   for (ArrayRef::iterator I = Values.begin(),
@@ -1307,7 +1307,7 @@ RegionStoreManager::invalidateRegions(St
   }
 
   RegionBindingsRef B = getRegionBindings(store);
-  invalidateRegionsWorker W(*this, StateMgr, B, Ex, Count, LCtx, IS, ITraits,
+  InvalidateRegionsWorker W(*this, StateMgr, B, Ex, Count, LCtx, IS, ITraits,
 Invalidated, GlobalsFilter);
 
   // Scan the bindings and generate the clusters.
@@ -2390,24 +2390,24 @@ RegionStoreManager::bindAggregate(Region
 
//===--

[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D51441#1218034, @yaxunl wrote:

> In https://reviews.llvm.org/D51441#1218010, @tra wrote:
>
> > While we're here, perhaps `Builder.defineMacro("__linux__")` should be 
> > changed to `DefineStd("linux")` which defines `linux/__linux/__linux__`?
>
>
> Will do when committing. Thanks.


Sorry DefineStd is a function not available in InitPreprocessor.cpp. To reuse 
that function refactoring is required, which is out of scope for this patch.


https://reviews.llvm.org/D51441



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


[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives

2018-08-29 Thread Ravi Narayanaswamy via Phabricator via cfe-commits
RaviNarayanaswamy added a comment.

We should just go with generating an error if the DeclareTargetNestingLevel is 
not 0 at the end of compilation unit.  
Hard to detect if user accidentally forgot to have end declare in header file 
and had it in the include file or it was intentional.


Repository:
  rC Clang

https://reviews.llvm.org/D51378



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


[PATCH] D46140: [coroutines] std::task type (WIP)

2018-08-29 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: jfb.

LGTM

With couple of suggestions.

1. Remove swap. It is not part of the proposal at the moment.
2. If you feel like, add a lazy alias to task, that way we can taste both 
names and see how it feels.

My apologies for taking so long to review.


https://reviews.llvm.org/D46140



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


[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives

2018-08-29 Thread Patrick Lyster via Phabricator via cfe-commits
patricklyster added a comment.

In https://reviews.llvm.org/D51378#1216600, @RaviNarayanaswamy wrote:

> Is there a way to tell if the header files have matching omp declare 
> target/omp end declare target.  
>  The reason is if one of the header files is missing a matching omp end 
> declare target all files which include it will end up having everything 
> marked with declare target


Are you suggesting to throw a warning/error at the end of the header file 
should there be a hanging `omp declare target`? Wouldn't this still be the same 
issue with each file that includes it still getting the same warning/error?

There is a corner case when the header file is missing the `end declare target` 
and the file that includes it has an extra `end declare target`. In this case 
no error will be thrown and all code in between the directives will be 
associated with the declare target. However, I don't know if this is something 
worth checking for.


Repository:
  rC Clang

https://reviews.llvm.org/D51378



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


[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Let's commit then?


https://reviews.llvm.org/D50892



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


[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-08-29 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I managed to cause a bunch of crashes with this patch, so consider it as a work 
in progress for now :/


https://reviews.llvm.org/D51057



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


[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

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



Comment at: test/Analysis/cxx-uninitialized-object-inheritance.cpp:802
+struct DynTBase2 {
+  int x; // expected-note{{uninitialized field 'static_cast(this->bptr)->DynTBase2::x'}}
+};

NoQ wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > Mmm, what's the value of casting to derived type and then specifying that 
> > > we access the field of the base type anyway? Isn't `this->bptr->x` 
> > > exactly what the user needs to know(?)
> > True, but it's a one tough job to write `this->bptr->x` here and also a 
> > correct note message for...
> I guess don't try too hard, eg. say if it requires something of non-linear 
> complexity it's probably not worth it (not because it'd be slow but because 
> it'd be an indication that it might be not worth the effort).
I actually invested some effort into this and I'm fairly certain I could pull 
it off with O(n) complexity, but I'll probably just place a TODO in the code 
for now, as I have other things I really want to get fixed first.


https://reviews.llvm.org/D50892



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


[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In https://reviews.llvm.org/D51434#1218017, @yaxunl wrote:

> In https://reviews.llvm.org/D51434#1217971, @arsenm wrote:
>
> > https://reviews.llvm.org/D51209 is the patch. I think HIP will need an 
> > additional patch, since I think it isn’t subclassing the amdgpu toolchain
>
>
> Yes since HIP has different toolchain. This does not affect kernel's 
> visibility, right?


It does, but the visibility of the kernel shouldn't matter


https://reviews.llvm.org/D51434



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


[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D51441#1218010, @tra wrote:

> While we're here, perhaps `Builder.defineMacro("__linux__")` should be 
> changed to `DefineStd("linux")` which defines `linux/__linux/__linux__`?


Will do when committing. Thanks.


https://reviews.llvm.org/D51441



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


[PATCH] D49074: [Analyzer] [WIP] Basic support for multiplication and division in the constraint manager

2018-08-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> where addition and subtraction is already supported?

Is it though? From what I recall we had to disable it from the default set of 
options due to the fact that it gives rise to the exponential running time in 
some cases.
I am somewhat afraid of similar unexpected side-effects from this and 
subsequent patches.


https://reviews.llvm.org/D49074



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


[PATCH] D51416: [RTTI] Align rtti type string to prevent over-alignment

2018-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Could we make CreateOrReplaceCXXRuntimeVariable take the alignment as an 
argument, so we can be sure we're consistently setting the alignment for these 
variables?  This seems easy to mess up if we're scattering calls all over the 
place.

Sort of orthogonal, but CreateOrReplaceCXXRuntimeVariable should probably also 
call setUnnamedAddr, instead of making each caller call it.


https://reviews.llvm.org/D51416



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


[PATCH] D51329: [Attribute/Diagnostics] Print macro instead of whole attribute for address_space

2018-08-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: lib/AST/TypePrinter.cpp:1370
+
+// Remove the underlying address space so it won't be printed.
+SplitQualType SplitTy = T->getModifiedType().split();

rsmith wrote:
> leonardchan wrote:
> > rsmith wrote:
> > > This is unnecessary; just print the modified type here. (The modified 
> > > type by definition does not have the attribute applied to it.)
> > When you say the modified type, do you mean just the type without it's 
> > qualifiers? I wasn't sure if removing all the qualifiers would suffice 
> > since there were also other  non-address_space qualifiers that could be 
> > printed.
> I mean `T->getModifiedType()`, which tracks what the type was before the 
> attribute was applied.
Oh, I understand that you meant `T->getModifiedType()`. This is a special case 
when printing the `address_space` since even though the attribute is applied 
and printed here, when we reach the qualifiers of the modified type, the 
address space will still be printed unless we remove it here.

I'm not sure if there's a better way to do this though.


Repository:
  rC Clang

https://reviews.llvm.org/D51329



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


[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/cxx-uninitialized-object-inheritance.cpp:802
+struct DynTBase2 {
+  int x; // expected-note{{uninitialized field 'static_cast(this->bptr)->DynTBase2::x'}}
+};

Szelethus wrote:
> NoQ wrote:
> > Mmm, what's the value of casting to derived type and then specifying that 
> > we access the field of the base type anyway? Isn't `this->bptr->x` exactly 
> > what the user needs to know(?)
> True, but it's a one tough job to write `this->bptr->x` here and also a 
> correct note message for...
I guess don't try too hard, eg. say if it requires something of non-linear 
complexity it's probably not worth it (not because it'd be slow but because 
it'd be an indication that it might be not worth the effort).


https://reviews.llvm.org/D50892



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


[PATCH] D51329: [Attribute/Diagnostics] Print macro instead of whole attribute for address_space

2018-08-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 163155.

Repository:
  rC Clang

https://reviews.llvm.org/D51329

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Lex/Preprocessor.h
  include/clang/Sema/ParsedAttr.h
  lib/AST/ASTContext.cpp
  lib/AST/TypePrinter.cpp
  lib/Lex/PPDirectives.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaType.cpp
  test/Sema/address_space_print_macro.c
  test/Sema/address_spaces.c

Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -71,5 +71,5 @@
 
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
 }
Index: test/Sema/address_space_print_macro.c
===
--- /dev/null
+++ test/Sema/address_space_print_macro.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(2), annotate("foo")))
+
+#define AS(i) address_space(i)
+#define AS3 __attribute__((AS(3)))
+
+char *cmp(AS1 char *x, AS2 char *y) {
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
+}
+
+__attribute__((address_space(1))) char test_array[10];
+void test3(void) {
+  extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
+  test3_helper(test_array);  // expected-error{{passing '__attribute__((address_space(1))) char *' to parameter of type 'char *' changes address space of pointer}}
+}
+
+char AS2 *test4_array;
+void test4(void) {
+  extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
+  test3_helper(test4_array); // expected-error{{passing 'AS2 char *' to parameter of type 'char *' changes address space of pointer}}
+}
+
+void func() {
+  char AS1 *x;
+  char AS3 *x2;
+  char *y;
+  y = x;  // expected-error{{assigning 'AS1 char *' to 'char *' changes address space of pointer}}
+  y = x2; // expected-error{{assigning 'AS3 char *' to 'char *' changes address space of pointer}}
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -243,9 +243,10 @@
 /// Get an attributed type for the given attribute, and remember the Attr
 /// object so that we can attach it to the AttributedTypeLoc.
 QualType getAttributedType(Attr *A, QualType ModifiedType,
-   QualType EquivType) {
-  QualType T =
-  sema.Context.getAttributedType(A->getKind(), ModifiedType, EquivType);
+   QualType EquivType,
+   IdentifierInfo *MacroII = nullptr) {
+  QualType T = sema.Context.getAttributedType(A->getKind(), ModifiedType,
+  EquivType, MacroII);
   AttrsForTypes.push_back({cast(T.getTypePtr()), A});
   AttrsForTypesSorted = false;
   return T;
@@ -5817,7 +5818,7 @@
   auto *ASAttr = ::new (Ctx) AddressSpaceAttr(
   Attr.getRange(), Ctx, Attr.getAttributeSpellingListIndex(),
   static_cast(T.getQualifiers().getAddressSpace()));
-  Type = State.getAttributedType(ASAttr, T, T);
+  Type = State.getAttributedType(ASAttr, T, T, Attr.getMacroII());
 } else {
   Attr.setInvalid();
 }
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -87,6 +87,39 @@
 #undef CLANG_ATTR_LATE_PARSED_LIST
 }
 
+static bool SourceLocInSourceRange(SourceLocation SpellingLoc,
+   SourceRange Range, const SourceManager &SM) {
+  SourceLocation RangeStart = Range.getBegin();
+  SourceLocation RangeEnd = Range.getEnd();
+  unsigned LineNo = SM.getSpellingLineNumber(SpellingLoc);
+  unsigned StartLineNo = SM.getSpellingLineNumber(RangeStart);
+  unsigned EndLineNo = SM.getSpellingLineNumber(RangeEnd);
+  unsigned ColNo = SM.getSpellingColumnNumber(SpellingLoc);
+  unsigned StartColNo = SM.getSpellingColumnNumber(RangeStart);
+  unsigned EndColNo = SM.getSpellingColumnNumber(RangeEnd);
+
+  // Outside of lines
+  if (LineNo < StartLineNo || LineNo > EndLineNo)
+return false;
+
+  // 

[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D51434#1217971, @arsenm wrote:

> https://reviews.llvm.org/D51209 is the patch. I think HIP will need an 
> additional patch, since I think it isn’t subclassing the amdgpu toolchain


Yes since HIP has different toolchain. This does not affect kernel's 
visibility, right?


https://reviews.llvm.org/D51434



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


r340954 - Revert "[libFuzzer] Port to Windows"

2018-08-29 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Aug 29 11:40:41 2018
New Revision: 340954

URL: http://llvm.org/viewvc/llvm-project?rev=340954&view=rev
Log:
Revert "[libFuzzer] Port to Windows"

This reverts r340949 due to bot breakage again.

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

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=340954&r1=340953&r2=340954&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Wed Aug 29 11:40:41 2018
@@ -365,17 +365,6 @@ void visualstudio::Linker::ConstructJob(
 CmdArgs.push_back(Args.MakeArgString(std::string("-implib:") + 
ImplibName));
   }
 
-  if (TC.getSanitizerArgs().needsFuzzer()) {
-if (!Args.hasArg(options::OPT_shared))
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-wholearchive:") +
- TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
-CmdArgs.push_back(Args.MakeArgString("-debug"));
-// Prevent the linker from padding sections we use for instrumentation
-// arrays.
-CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
-  }
-
   if (TC.getSanitizerArgs().needsAsanRt()) {
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
@@ -1309,8 +1298,6 @@ MSVCToolChain::ComputeEffectiveClangTrip
 SanitizerMask MSVCToolChain::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
-  Res |= SanitizerKind::Fuzzer;
-  Res |= SanitizerKind::FuzzerNoLink;
   Res &= ~SanitizerKind::CFIMFCall;
   return Res;
 }


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


[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

While we're here, perhaps `Builder.defineMacro("__linux__")` should be changed 
to `DefineStd("linux")` which defines `linux/__linux/__linux__`?


https://reviews.llvm.org/D51441



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


[PATCH] D51448: [WebAssembly] clang-format (NFC)

2018-08-29 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
Herald added subscribers: cfe-commits, jfb, sunfish, jgravelle-google, sbc100, 
dschuff.

This patch runs clang-format on all wasm-only files.


Repository:
  rC Clang

https://reviews.llvm.org/D51448

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h
  test/CodeGen/builtins-wasm.c
  test/CodeGen/wasm-arguments.c
  test/CodeGen/wasm-varargs.c
  test/CodeGenCXX/static-init-wasm.cpp
  test/CodeGenCXX/wasm-args-returns.cpp
  test/Driver/wasm32-unknown-unknown.cpp
  test/Driver/wasm64-unknown-unknown.cpp

Index: test/Driver/wasm64-unknown-unknown.cpp
===
--- test/Driver/wasm64-unknown-unknown.cpp
+++ test/Driver/wasm64-unknown-unknown.cpp
@@ -29,7 +29,7 @@
 int align_ll = __alignof(long long);
 
 // CHECK: @align_p = hidden global i32 8
-int align_p = __alignof(void*);
+int align_p = __alignof(void *);
 
 // CHECK: @align_f = hidden global i32 4
 int align_f = __alignof(float);
@@ -99,17 +99,20 @@
 
 // CHECK: fp128 @check_longdouble()
 long double check_longdouble() { return 0; }
-
 }
 
-template void Switch();
-template<> void Switch<4>();
-template<> void Switch<8>();
-template<> void Switch<16>();
+template 
+void Switch();
+template <>
+void Switch<4>();
+template <>
+void Switch<8>();
+template <>
+void Switch<16>();
 
 void check_pointer_size() {
   // CHECK: SwitchILi8
-  Switch();
+  Switch();
 
   // CHECK: SwitchILi8
   Switch();
Index: test/Driver/wasm32-unknown-unknown.cpp
===
--- test/Driver/wasm32-unknown-unknown.cpp
+++ test/Driver/wasm32-unknown-unknown.cpp
@@ -29,7 +29,7 @@
 int align_ll = __alignof(long long);
 
 // CHECK: @align_p = hidden global i32 4
-int align_p = __alignof(void*);
+int align_p = __alignof(void *);
 
 // CHECK: @align_f = hidden global i32 4
 int align_f = __alignof(float);
@@ -99,17 +99,20 @@
 
 // CHECK: fp128 @check_longdouble()
 long double check_longdouble() { return 0; }
-
 }
 
-template void Switch();
-template<> void Switch<4>();
-template<> void Switch<8>();
-template<> void Switch<16>();
+template 
+void Switch();
+template <>
+void Switch<4>();
+template <>
+void Switch<8>();
+template <>
+void Switch<16>();
 
 void check_pointer_size() {
   // CHECK: SwitchILi4
-  Switch();
+  Switch();
 
   // CHECK: SwitchILi8
   Switch();
Index: test/CodeGenCXX/wasm-args-returns.cpp
===
--- test/CodeGenCXX/wasm-args-returns.cpp
+++ test/CodeGenCXX/wasm-args-returns.cpp
@@ -3,16 +3,18 @@
 // RUN: %clang_cc1 -O1 -triple wasm64-unknown-unknown -emit-llvm -o - %s \
 // RUN:   | FileCheck %s
 
-#define concat_(x, y) x ## y
+#define concat_(x, y) x##y
 #define concat(x, y) concat_(x, y)
 
-#define test(T) \
+#define test(T)\
   T forward(T x) { return x; } \
-  void use(T x); \
-  T concat(def_, T)(void); \
+  void use(T x);   \
+  T concat(def_, T)(void); \
   void concat(test_, T)(void) { use(concat(def_, T)()); }
 
-struct one_field { double d; };
+struct one_field {
+  double d;
+};
 test(one_field);
 // CHECK: define double @_Z7forward9one_field(double returned %{{.*}})
 //
@@ -24,7 +26,9 @@
 // CHECK: declare void @_Z3use9one_field(double)
 // CHECK: declare double @_Z13def_one_fieldv()
 
-struct two_fields { double d, e; };
+struct two_fields {
+  double d, e;
+};
 test(two_fields);
 // CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 %{{.*}})
 //
@@ -38,8 +42,8 @@
 // CHECK: declare void @_Z14def_two_fieldsv(%struct.two_fields* sret)
 
 struct copy_ctor {
-double d;
-copy_ctor(copy_ctor const&);
+  double d;
+  copy_ctor(copy_ctor const &);
 };
 test(copy_ctor);
 // CHECK: define void @_Z7forward9copy_ctor(%struct.copy_ctor* noalias sret %{{.*}}, %struct.copy_ctor* %{{.*}})
@@ -56,8 +60,8 @@
 // CHECK: declare void @_Z13def_copy_ctorv(%struct.copy_ctor* sret)
 
 struct __attribute__((aligned(16))) aligned_copy_ctor {
-double d, e;
-aligned_copy_ctor(aligned_copy_ctor const&);
+  double d, e;
+  aligned_copy_ctor(aligned_copy_ctor const &);
 };
 test(aligned_copy_ctor);
 // CHECK: define void @_Z7forward17aligned_copy_ctor(%struct.aligned_copy_ctor* noalias sret %{{.*}}, %struct.aligned_copy_ctor* %{{.*}})
@@ -86,7 +90,7 @@
 // CHECK: declare void @_Z9def_emptyv()
 
 struct one_bitfield {
-int d:3;
+  int d : 3;
 };
 test(one_bitfield);
 // CHECK: define i32 @_Z7forward12one_bitfield(i32 returned %{{.*}})
Index: test/CodeGenCXX/static-init-wasm.cpp
===
--- test/CodeGenCXX/static-init-wasm.cpp
+++ test/CodeGenCXX/static-init-wasm.cpp
@@ -38,7 +38,7 @@
 
 // Test various aspects of static constructor calls.
 struct A {
-A();
+  A();
 };
 
 A theA;
Index: test/CodeGen/wasm-varargs.c

r340953 - [OPENMP][NVPTX] Add support for lightweight runtime.

2018-08-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 29 11:32:21 2018
New Revision: 340953

URL: http://llvm.org/viewvc/llvm-project?rev=340953&view=rev
Log:
[OPENMP][NVPTX] Add support for lightweight runtime.

If the target construct can be executed in SPMD mode + it is a loop
based directive with static scheduling, we can use lightweight runtime
support.

Added:
cfe/trunk/test/OpenMP/nvptx_SPMD_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_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_teams_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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=340953&r1=340952&r2=340953&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Aug 29 11:32:21 2018
@@ -672,11 +672,19 @@ static bool hasParallelIfNumThreadsClaus
   return false;
 }
 
+/// Checks if the directive is the distribute clause with the lastprivate
+/// clauses. This construct does not support SPMD execution mode.
+static bool hasDistributeWithLastprivateClauses(const OMPExecutableDirective 
&D) {
+  return isOpenMPDistributeDirective(D.getDirectiveKind()) &&
+ D.hasClausesOfKind();
+}
+
 /// Check for inner (nested) SPMD construct, if any
 static bool hasNestedSPMDDirective(ASTContext &Ctx,
const OMPExecutableDirective &D) {
   const auto *CS = D.getInnermostCapturedStmt();
-  const auto *Body = CS->getCapturedStmt()->IgnoreContainers();
+  const auto *Body =
+  CS->getCapturedStmt()->IgnoreContainers(/*IgnoreCaptured=*/true);
   const Stmt *ChildStmt = getSingleCompoundChild(Body);
 
   if (const auto *NestedDir = dyn_cast(ChildStmt)) {
@@ -684,29 +692,221 @@ static bool hasNestedSPMDDirective(ASTCo
 switch (D.getDirectiveKind()) {
 case OMPD_target:
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfNumThreadsClause(Ctx, *NestedDir))
+  !hasParallelIfNumThreadsClause(Ctx, *NestedDir) &&
+  !hasDistributeWithLastprivateClauses(*NestedDir))
 return true;
-  if (DKind == OMPD_teams || DKind == OMPD_teams_distribute) {
-Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
+  if (DKind == OMPD_teams) {
+Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers(
+/*IgnoreCaptured=*/true);
 if (!Body)
   return false;
 ChildStmt = getSingleCompoundChild(Body);
 if (const auto *NND = dyn_cast(ChildStmt)) {
   DKind = NND->getDirectiveKind();
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfNumThreadsClause(Ctx, *NND))
+  !hasParallelIfNumThreadsClause(Ctx, *NND) &&
+  !hasDistributeWithLastprivateClauses(*NND))
 return true;
-  if (DKind == OMPD_distribute) {
-Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
+}
+  }
+  return false;
+case OMPD_target_teams:
+  return isOpenMPParallelDirective(DKind) &&
+ !hasParallelIfNumThreadsClause(Ctx, *NestedDir) &&
+ !hasDistributeWithLastprivateClauses(*NestedDir);
+case OMPD_target_simd:
+case OMPD_target_parallel:
+case OMPD_target_parallel_for:
+case OMPD_target_parallel_for_simd:
+case OMPD_target_teams_distribute:
+case OMPD_target_teams_distribute_simd:
+case OMPD_target_teams_distribute_parallel_for:
+case OMPD_target_teams_distribute_parallel_for_simd:
+case OMPD_parallel:
+case OMPD_for:
+case OMPD_parallel_for:
+case OMPD_parallel_sections:
+case OMPD_for_simd:
+case OMPD_parallel_for_simd:
+case OMPD_cancel:
+case OMPD_cancellation_point:
+case OMPD_ordered:
+case OMPD_threadprivate:
+case OMPD_task:
+case OMPD_simd:
+case OMPD_sections:
+case OMPD_section:
+case OMPD_single:
+case OMPD_master:
+case OMPD_critical:
+case OMPD_taskyield:
+case OMPD_barrier:
+case OMPD_taskwait:
+case OMPD_taskgroup:
+case OMPD_atomic:
+case OMPD_flush:
+case OMPD_teams:
+case OMPD_target_data:
+case OMPD_target_exit_data:
+case OMPD_target_enter_data:
+case OMPD_distribute:
+case OMPD_distribute_simd:
+case OMPD_distribute_parallel_for:
+case OMPD_

[PATCH] D51381: [clang-tidy] fix check_clang_tidy to properly mix CHECK-NOTES and CHECK-MESSAGES

2018-08-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D51381#1217047, @JonasToth wrote:

> @lebedev.ri lets do it in the the other patch, to not split discussions.


Let's do it here instead, since that differential requires some changes to this 
script.

In https://reviews.llvm.org/D51381#1217047, @JonasToth wrote:

> But what do you mean by `You would still have to duplicate the check-lines 
> for error: though.`?


In it's current state, `CHECK-MESSAGES` implies 
`-implicit-check-not={{warning|error}}`,
and `CHECK-NOTES` will imply `-implicit-check-not={{note|error}}`.
I.e. they both imply `-implicit-check-not=error`.
So **if** the check produces any `error:` output, **and** you want to use 
**both** the `CHECK-NOTES` and `CHECK-MESSAGES`,
you need to write the check-line for every `error: ` with both the 
`CHECK-NOTES` and `CHECK-MESSAGES` prefixes. 
This seems sub-optimal.

In https://reviews.llvm.org/D48714#1217044, @JonasToth wrote:

> In https://reviews.llvm.org/D48714#1216989, @lebedev.ri wrote:
>
> > In https://reviews.llvm.org/D48714#1216537, @JonasToth wrote:
> >
> > > I had to revert the `CHECK-NOTES` change that @lebedev.ri introduced with 
> > > his revision. It fails the test, i think there is an inconsistency or so 
> > > in the check-clang-tidy script. I will try to figure out whats the issue.
> >
> >
> > So what was the issue? Do you get the same results if you undo the 
> > https://reviews.llvm.org/D51381 and `s/CHECK-MESSAGES/CHECK-NOTES/`?
>
>
> You are right that replacing all of it with `CHECK-NOTES` works as well.
>  `FileCheck` is run twice if you have `FIXMES` as well. Having another run 
> for the notes is consistent with how it worked before.
>  If we go for the catch-all-with-one approach it might be a good idea to 
> ensure that only one of `CHECK-MESSAGES` or `CHECK-NOTES` is present in the 
> file and adjust the check_clang_tidy.py script a little.


I don't have a //strong// preference, but if that works i would **prefer** to 
go that route, since that is what the initial intended semantics of the 
`CHECK-NOTES`.
**If** that works for you?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51381



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


[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

https://reviews.llvm.org/D51209 is the patch. I think HIP will need an 
additional patch, since I think it isn’t subclassing the amdgpu toolchain


https://reviews.llvm.org/D51434



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


[PATCH] D51440: [ToolChains] Link to compiler-rt with -L + -l when possible

2018-08-29 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In https://reviews.llvm.org/D51440#1217910, @mstorsjo wrote:

> In https://reviews.llvm.org/D51440#1217839, @manojgupta wrote:
>
> > Just a minor comment regarding test cases: Since you are adding both 
> > -L/path/ and -l,  the test cases should be updated to  check for 
> > the -L/path/ argument as well.
>
>
> I guess I could do that, although we don't know the path in the test, so we 
> can only check for `-L.*`.


You can add a testcase that passes a known path via -resource-dir=path argument 
similar to --sysroot argument.


Repository:
  rC Clang

https://reviews.llvm.org/D51440



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


[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I have a patch to change the default visibility which I think is a better option


https://reviews.llvm.org/D51434



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


[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 163145.
yaxunl added a comment.

Revised by Artem's comments.


https://reviews.llvm.org/D51441

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/predefined-macros.c


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -183,9 +183,11 @@
 // CHECK-HIP: #define __HIP__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device \
+// RUN:   -aux-triple x86_64-unknown-linux -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV
 // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV: #define __HIPCC__ 1
 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-DEV: #define __HIP__ 1
+// CHECK_HIP-DEV: #define __linux__ 1
+// CHECK_HIP-DEV: #define __gnu_linux__ 1
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1123,6 +1123,7 @@
   if (AuxTriple.getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__linux__");
+Builder.defineMacro("__gnu_linux__");
 // Used in features.h. If this is omitted, math.h doesn't declare float
 // versions of the functions in bits/mathcalls.h.
 if (LangOpts.CPlusPlus)


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -183,9 +183,11 @@
 // CHECK-HIP: #define __HIP__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device \
+// RUN:   -aux-triple x86_64-unknown-linux -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV
 // CHECK-HIP-DEV-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV: #define __HIPCC__ 1
 // CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-DEV: #define __HIP__ 1
+// CHECK_HIP-DEV: #define __linux__ 1
+// CHECK_HIP-DEV: #define __gnu_linux__ 1
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1123,6 +1123,7 @@
   if (AuxTriple.getOS() == llvm::Triple::Linux) {
 Builder.defineMacro("__ELF__");
 Builder.defineMacro("__linux__");
+Builder.defineMacro("__gnu_linux__");
 // Used in features.h. If this is omitted, math.h doesn't declare float
 // versions of the functions in bits/mathcalls.h.
 if (LangOpts.CPlusPlus)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a reviewer: arsenm.
scott.linder added a comment.

+Matt to confirm, but our executable format is a shared object and we 
eventually want to support preemptible symbols through the PLT. We already 
generate GOT entries for globals.

Currently we work around the lack of PLT support by internalizing all 
non-kernel functions, so for now this patch is required.


https://reviews.llvm.org/D51434



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


r340949 - [libFuzzer] Port to Windows

2018-08-29 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Aug 29 11:08:34 2018
New Revision: 340949

URL: http://llvm.org/viewvc/llvm-project?rev=340949&view=rev
Log:
[libFuzzer] Port to Windows

Summary:
Port libFuzzer to windows-msvc.
This patch allows libFuzzer targets to be built and run on Windows, using 
-fsanitize=fuzzer and/or fsanitize=fuzzer-no-link. It allows these forms of 
coverage instrumentation to work on Windows as well.
It does not fix all issues, such as those with -fsanitize-coverage=stack-depth, 
which is not usable on Windows as of this patch.
It also does not fix any libFuzzer integration tests. Nearly all of them fail 
to compile, fixing them will come in a later patch, so libFuzzer tests are 
disabled on Windows until them.

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: #sanitizers, delcypher, morehouse, kcc, eraman

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=340949&r1=340948&r2=340949&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Wed Aug 29 11:08:34 2018
@@ -365,6 +365,17 @@ void visualstudio::Linker::ConstructJob(
 CmdArgs.push_back(Args.MakeArgString(std::string("-implib:") + 
ImplibName));
   }
 
+  if (TC.getSanitizerArgs().needsFuzzer()) {
+if (!Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("-wholearchive:") +
+ TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
+CmdArgs.push_back(Args.MakeArgString("-debug"));
+// Prevent the linker from padding sections we use for instrumentation
+// arrays.
+CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
+  }
+
   if (TC.getSanitizerArgs().needsAsanRt()) {
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
@@ -1298,6 +1309,8 @@ MSVCToolChain::ComputeEffectiveClangTrip
 SanitizerMask MSVCToolChain::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res &= ~SanitizerKind::CFIMFCall;
   return Res;
 }


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


[PATCH] D51446: [OpenMP][bugfix] Add missing macros for Power

2018-08-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, Hahnfeld, caomhin.
Herald added subscribers: cfe-commits, guansong.

Add missing macros when the auxiliary triple points to the PPC architecture.


Repository:
  rC Clang

https://reviews.llvm.org/D51446

Files:
  lib/Frontend/InitPreprocessor.cpp


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1113,10 +1113,18 @@
 Builder.defineMacro("__x86_64__");
 break;
   case llvm::Triple::ppc64:
+if (AuxTI.getLongDoubleWidth() == 128) {
+  Builder.defineMacro("__LONG_DOUBLE_128__");
+  Builder.defineMacro("__LONGDOUBLE128");
+}
 Builder.defineMacro("__powerpc64__");
 Builder.defineMacro("_CALL_ELF", "1");
 break;
   case llvm::Triple::ppc64le:
+if (AuxTI.getLongDoubleWidth() == 128) {
+  Builder.defineMacro("__LONG_DOUBLE_128__");
+  Builder.defineMacro("__LONGDOUBLE128");
+}
 Builder.defineMacro("__powerpc64__");
 Builder.defineMacro("_CALL_ELF", "2");
 break;


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -1113,10 +1113,18 @@
 Builder.defineMacro("__x86_64__");
 break;
   case llvm::Triple::ppc64:
+if (AuxTI.getLongDoubleWidth() == 128) {
+  Builder.defineMacro("__LONG_DOUBLE_128__");
+  Builder.defineMacro("__LONGDOUBLE128");
+}
 Builder.defineMacro("__powerpc64__");
 Builder.defineMacro("_CALL_ELF", "1");
 break;
   case llvm::Triple::ppc64le:
+if (AuxTI.getLongDoubleWidth() == 128) {
+  Builder.defineMacro("__LONG_DOUBLE_128__");
+  Builder.defineMacro("__LONGDOUBLE128");
+}
 Builder.defineMacro("__powerpc64__");
 Builder.defineMacro("_CALL_ELF", "2");
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51359: Adding HardLink Support to VirtualFileSystem.

2018-08-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Could we try removing `Status` from the base class and move it into 
`InMemoryFile` and `InMemoryDir`?
It shouldn't be too much work and would give safer interfaces for our new 
hierarchy.




Comment at: lib/Basic/VirtualFileSystem.cpp:470
 
-enum InMemoryNodeKind { IME_File, IME_Directory };
+enum InMemoryNodeKind { IME_File, IME_Directory, IME_HARD_LINK };
 

NIT: maybe use a name that follow the naming style for the other node kinds, 
i.e. IME_HardLink?



Comment at: lib/Basic/VirtualFileSystem.cpp:526
+  InMemoryNode *ResolvedNode;
+  StringRef Name;
+

Can we get away without storing `Name`? `toString()` can just say `"hard link 
to "  + ResolveNode->toString()`



Comment at: lib/Basic/VirtualFileSystem.cpp:529
+public:
+  InMemoryHardLink(Status Stat, InMemoryNode *ResolvedNode)
+  : InMemoryNode(std::move(Stat), IME_HARD_LINK),

Why do we need the Stat?
We can get it from `ResolveNode` if we want to store a copy. Any reason why it 
would be different?



Comment at: lib/Basic/VirtualFileSystem.cpp:529
+public:
+  InMemoryHardLink(Status Stat, InMemoryNode *ResolvedNode)
+  : InMemoryNode(std::move(Stat), IME_HARD_LINK),

ilya-biryukov wrote:
> Why do we need the Stat?
> We can get it from `ResolveNode` if we want to store a copy. Any reason why 
> it would be different?
ResolveNode can't be `null`, right? Maybe use a reference instead?
Also, maybe make it const?



Comment at: lib/Basic/VirtualFileSystem.cpp:535
+  InMemoryNode *getResolvedNode() { return ResolvedNode; }
+  llvm::MemoryBuffer *getBuffer() {
+return static_cast(ResolvedNode)->getBuffer();

Could we inline `getBuffer` and `getStatus`? Having the client code that's 
explicit about resolving the references seems like a good idea.



Comment at: lib/Basic/VirtualFileSystem.cpp:639
+ Optional Perms,
+ Optional HardLink) {
   SmallString<128> Path;

Why not just `InMemoryNode*`? Null would be the empty hardlink



Comment at: lib/Basic/VirtualFileSystem.cpp:782
+// If Node is HardLink then return the resolved link.
+if (auto File = dyn_cast(Node)) {
+  if (I == E)

NIT: maybe call the variable Link or HardLink?
Since it's not a file.



Comment at: unittests/Basic/VirtualFileSystemTest.cpp:1054
+  EXPECT_FALSE(FS.addHardLink(link, dir));
+}
+

Maybe also add a test that gets into hard links via directory iterators?
To make sure those give the same results as `openFileForRead`


Repository:
  rC Clang

https://reviews.llvm.org/D51359



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


[PATCH] D51440: [ToolChains] Link to compiler-rt with -L + -l when possible

2018-08-29 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D51440#1217839, @manojgupta wrote:

> Just a minor comment regarding test cases: Since you are adding both -L/path/ 
> and -l,  the test cases should be updated to  check for the -L/path/ 
> argument as well.


I guess I could do that, although we don't know the path in the test, so we can 
only check for `-L.*`.

In https://reviews.llvm.org/D51440#1217868, @lebedev.ri wrote:

> Since the libraries will no longer be specified with their full path, how 
> will you know that the **right** library will be picked, the one compiler 
> intended?


We don't; the same goes for libgcc. I guess the risk for unintentional clashes 
is rather low; if the linker found another lib with the same name, I would 
expect it to be intentional, and using it wouldn't be wrong.


Repository:
  rC Clang

https://reviews.llvm.org/D51440



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


[PATCH] D51441: Add predefined macro __gnu_linux__ for proper aux-triple

2018-08-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:1126
 Builder.defineMacro("__linux__");
+if (AuxTriple.getEnvironment() == llvm::Triple::GNU)
+  Builder.defineMacro("__gnu_linux__");

AFAICT, we always define `__gnu_linix__` on Linux:
https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets/OSTargets.h#L306

I think it should be the case here, too.


https://reviews.llvm.org/D51441



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


[PATCH] D51440: [ToolChains] Link to compiler-rt with -L + -l when possible

2018-08-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Since the libraries will no longer be specified with their full path, how will 
you know that the **right** library will be picked, the one compiler intended?


Repository:
  rC Clang

https://reviews.llvm.org/D51440



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


[PATCH] D51440: [ToolChains] Link to compiler-rt with -L + -l when possible

2018-08-29 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Just a minor comment regarding test cases: Since you are adding both -L/path/ 
and -l,  the test cases should be updated to  check for the -L/path/ 
argument as well.


Repository:
  rC Clang

https://reviews.llvm.org/D51440



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


r340941 - [MinGW] Don't mark external variables as DSO local

2018-08-29 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Aug 29 10:26:58 2018
New Revision: 340941

URL: http://llvm.org/viewvc/llvm-project?rev=340941&view=rev
Log:
[MinGW] Don't mark external variables as DSO local

Since MinGW supports automatically importing external variables from
DLLs even without the DLLImport attribute, we shouldn't mark them
as DSO local unless we actually know them to be local for sure.

Keep marking thread local variables as DSO local.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/dllimport.c
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dllexport.cpp
cfe/trunk/test/CodeGenCXX/dllimport-members.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=340941&r1=340940&r2=340941&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Aug 29 10:26:58 2018
@@ -730,6 +730,14 @@ static bool shouldAssumeDSOLocal(const C
 return false;
 
   const llvm::Triple &TT = CGM.getTriple();
+  if (TT.isWindowsGNUEnvironment()) {
+// In MinGW, variables without DLLImport can still be automatically
+// imported from a DLL by the linker; don't mark variables that
+// potentially could come from another DLL as DSO local.
+if (GV->isDeclarationForLinker() && isa(GV) &&
+!GV->isThreadLocal())
+  return false;
+  }
   // Every other GV is local on COFF.
   // Make an exception for windows OS in the triple: Some firmware builds use
   // *-win32-macho triples. This (accidentally?) produced windows relocations

Modified: cfe/trunk/test/CodeGen/dllimport.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dllimport.c?rev=340941&r1=340940&r2=340941&view=diff
==
--- cfe/trunk/test/CodeGen/dllimport.c (original)
+++ cfe/trunk/test/CodeGen/dllimport.c Wed Aug 29 10:26:58 2018
@@ -39,7 +39,8 @@ USEVAR(GlobalRedecl2)
 
 // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
 // and drop the dllimport with a warning.
-// CHECK: @GlobalRedecl3 = external dso_local global i32
+// MS: @GlobalRedecl3 = external dso_local global i32
+// GNU: @GlobalRedecl3 = external global i32
 __declspec(dllimport) extern int GlobalRedecl3;
   extern int GlobalRedecl3; // dllimport ignored
 USEVAR(GlobalRedecl3)

Modified: cfe/trunk/test/CodeGen/dso-local-executable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dso-local-executable.c?rev=340941&r1=340940&r2=340941&view=diff
==
--- cfe/trunk/test/CodeGen/dso-local-executable.c (original)
+++ cfe/trunk/test/CodeGen/dso-local-executable.c Wed Aug 29 10:26:58 2018
@@ -9,6 +9,17 @@
 // COFF-DAG: @import_var = external dllimport global i32
 // COFF-DAG: declare dllimport void @import_func()
 
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
-allow-deprecated-dag-overlap --check-prefix=MINGW %s
+// MINGW-DAG: @bar = external global i32
+// MINGW-DAG: @weak_bar = extern_weak global i32
+// MINGW-DAG: declare dso_local void @foo()
+// MINGW-DAG: @baz = dso_local global i32 42
+// MINGW-DAG: define dso_local i32* @zed()
+// MINGW-DAG: @thread_var = external dso_local thread_local global i32
+// MINGW-DAG: @local_thread_var = dso_local thread_local global i32 42
+// MINGW-DAG: @import_var = external dllimport global i32
+// MINGW-DAG: declare dllimport void @import_func()
+
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -mrelocation-model 
static %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix=STATIC 
%s
 // STATIC-DAG: @bar = external dso_local global i32
 // STATIC-DAG: @weak_bar = extern_weak dso_local global i32

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=340941&r1=340940&r2=340941&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Wed Aug 29 10:26:58 2018
@@ -43,7 +43,7 @@ __declspec(dllexport) extern int ExternG
 
 // M64-DAG: @__ImageBase = external dso_local constant i8
 
-// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global
+// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external global
 
 // dllexport implies a definition.
 // MSC-DAG: @"?GlobalDef@@3HA" = dso_local dllexport global i32 0, align 4
@@ -137,7 +137,7 @@ class __declspec(dllexport) i : h<> {};
 // Declarations are not exported.
 
 // MSC-DA

[PATCH] D51382: [MinGW] Don't mark external variables as DSO local

2018-08-29 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340941: [MinGW] Don't mark external variables as DSO 
local (authored by mstorsjo, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51382

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/dllimport.c
  test/CodeGen/dso-local-executable.c
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport-members.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/dso-local-executable.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -730,6 +730,14 @@
 return false;
 
   const llvm::Triple &TT = CGM.getTriple();
+  if (TT.isWindowsGNUEnvironment()) {
+// In MinGW, variables without DLLImport can still be automatically
+// imported from a DLL by the linker; don't mark variables that
+// potentially could come from another DLL as DSO local.
+if (GV->isDeclarationForLinker() && isa(GV) &&
+!GV->isThreadLocal())
+  return false;
+  }
   // Every other GV is local on COFF.
   // Make an exception for windows OS in the triple: Some firmware builds use
   // *-win32-macho triples. This (accidentally?) produced windows relocations
Index: test/CodeGen/dllimport.c
===
--- test/CodeGen/dllimport.c
+++ test/CodeGen/dllimport.c
@@ -39,7 +39,8 @@
 
 // NB: MSVC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC
 // and drop the dllimport with a warning.
-// CHECK: @GlobalRedecl3 = external dso_local global i32
+// MS: @GlobalRedecl3 = external dso_local global i32
+// GNU: @GlobalRedecl3 = external global i32
 __declspec(dllimport) extern int GlobalRedecl3;
   extern int GlobalRedecl3; // dllimport ignored
 USEVAR(GlobalRedecl3)
Index: test/CodeGen/dso-local-executable.c
===
--- test/CodeGen/dso-local-executable.c
+++ test/CodeGen/dso-local-executable.c
@@ -9,6 +9,17 @@
 // COFF-DAG: @import_var = external dllimport global i32
 // COFF-DAG: declare dllimport void @import_func()
 
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix=MINGW %s
+// MINGW-DAG: @bar = external global i32
+// MINGW-DAG: @weak_bar = extern_weak global i32
+// MINGW-DAG: declare dso_local void @foo()
+// MINGW-DAG: @baz = dso_local global i32 42
+// MINGW-DAG: define dso_local i32* @zed()
+// MINGW-DAG: @thread_var = external dso_local thread_local global i32
+// MINGW-DAG: @local_thread_var = dso_local thread_local global i32 42
+// MINGW-DAG: @import_var = external dllimport global i32
+// MINGW-DAG: declare dllimport void @import_func()
+
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -mrelocation-model static %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix=STATIC %s
 // STATIC-DAG: @bar = external dso_local global i32
 // STATIC-DAG: @weak_bar = extern_weak dso_local global i32
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -43,7 +43,7 @@
 
 // M64-DAG: @__ImageBase = external dso_local constant i8
 
-// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global
+// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external global
 
 // dllexport implies a definition.
 // MSC-DAG: @"?GlobalDef@@3HA" = dso_local dllexport global i32 0, align 4
@@ -137,7 +137,7 @@
 // Declarations are not exported.
 
 // MSC-DAG: @"??$VarTmplImplicitDef@UImplicitInst_Exported3HA" = external dso_local global
-// GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE  = external dso_local global
+// GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE  = external global
 template __declspec(dllexport) extern int VarTmplImplicitDef;
 USEVAR(VarTmplImplicitDef)
 
Index: test/CodeGenCXX/dso-local-executable.cpp
===
--- test/CodeGenCXX/dso-local-executable.cpp
+++ test/CodeGenCXX/dso-local-executable.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -O1 -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -fno-plt -O1 -emit-llvm %s -o - | FileCheck --check-prefix=NOPLT %s
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -O1 -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
 
 // STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
 // STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant
@@ -19,6 +20,15 @@
 // NOPLT-DAG: define dso_local void @_ZN1CC1Ev(
 // NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
 
+// MINGW-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr consta

[PATCH] D51434: [HIP] Add -amdgpu-internalize-symbols option to opt

2018-08-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I could not find anything about PLTs in AMDGPU-ABI 
,
 nor could I find anything relevant on google.
I still have no idea why PLTs are required in this case. Without that info, the 
problem may as well be due to unintended requirement for PLT that this patch 
would hide.

I'm going to defer to someone more familiar with amdgpu to tell whether that's 
the right fix for the problem.


https://reviews.llvm.org/D51434



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


[PATCH] D51333: Diagnose likely typos in include statements

2018-08-29 Thread Christy Lee via Phabricator via cfe-commits
christylee updated this revision to Diff 163132.
christylee edited the summary of this revision.
christylee added a comment.

Merged warning with existing file_not_found_error.


https://reviews.llvm.org/D51333

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/PPDirectives.cpp
  lib/Lex/Pragma.cpp
  test/Preprocessor/include-likely-typo.c


Index: test/Preprocessor/include-likely-typo.c
===
--- /dev/null
+++ test/Preprocessor/include-likely-typo.c
@@ -0,0 +1,2 @@
+// RUN: not %clang_cc1 -verify -frewrite-includes
+#include "" @expected-error {{'' file not found, possibly 
due to leading or trailing non-alphanumeric characters in the file name}}
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -514,7 +514,7 @@
  nullptr, CurDir, nullptr, nullptr, nullptr, nullptr);
   if (!File) {
 if (!SuppressIncludeNotFoundError)
-  Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
+  Diag(FilenameTok, diag::err_pp_file_not_found) << Filename << 0;
 return;
   }
 
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1859,6 +1859,7 @@
   // If the file could not be located and it was included via angle
   // brackets, we can attempt a lookup as though it were a quoted path to
   // provide the user with a possible fixit.
+  bool isFileNotFoundLikelyTypo = false;
   if (isAngled) {
 File = LookupFile(
 FilenameLoc,
@@ -1868,16 +1869,27 @@
 Callbacks ? &RelativePath : nullptr, &SuggestedModule, &IsMapped);
 if (File) {
   SourceRange Range(FilenameTok.getLocation(), CharEnd);
-  Diag(FilenameTok, diag::err_pp_file_not_found_not_fatal) <<
-Filename <<
-FixItHint::CreateReplacement(Range, "\"" + Filename.str() + "\"");
+  Diag(FilenameTok, diag::err_pp_file_not_found_not_fatal)
+  << Filename
+  << FixItHint::CreateReplacement(Range,
+  "\"" + Filename.str() + "\"")
+  << isFileNotFoundLikelyTypo;
 }
   }
 
   // If the file is still not found, just go with the vanilla diagnostic
-  if (!File)
-Diag(FilenameTok, diag::err_pp_file_not_found) << Filename
-   << FilenameRange;
+  if (!File) {
+// Assuming filename logically starts and end with alphnumeric
+// character
+if (!isAlphanumeric(Filename.front()) ||
+!isAlphanumeric(Filename.back())) {
+  isFileNotFoundLikelyTypo = true;
+  Diag(FilenameTok, diag::err_pp_file_not_found)
+  << Filename << isFileNotFoundLikelyTypo;
+}
+Diag(FilenameTok, diag::err_pp_file_not_found)
+<< Filename << FilenameRange << isFileNotFoundLikelyTypo;
+  }
 }
   }
 
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -403,7 +403,9 @@
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;
-def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
+def err_pp_file_not_found : Error<
+  "'%0' file not found%select{|, possibly due to leading or trailing "
+  "non-alphanumeric characters in the file name}1">, DefaultFatal;
 def err_pp_through_header_not_found : Error<
   "'%0' required for precompiled header not found">, DefaultFatal;
 def err_pp_through_header_not_seen : Error<


Index: test/Preprocessor/include-likely-typo.c
===
--- /dev/null
+++ test/Preprocessor/include-likely-typo.c
@@ -0,0 +1,2 @@
+// RUN: not %clang_cc1 -verify -frewrite-includes
+#include "" @expected-error {{'' file not found, possibly due to leading or trailing non-alphanumeric characters in the file name}}
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -514,7 +514,7 @@
  nullptr, CurDir, nullptr, nullptr, nullptr, nullptr);
   if (!File) {
 if (!SuppressIncludeNotFoundError)
-  Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
+  Diag(FilenameTok, diag::err_pp_file_not_found) << Filename << 0;
 return;
   }
 
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1859,6 +1859,7 @@
   // If the file could not be located and it was included via angle
   

  1   2   >