r339031 - [Fixed Point Arithmetic] Remove unused include.

2018-08-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Aug  6 09:53:21 2018
New Revision: 339031

URL: http://llvm.org/viewvc/llvm-project?rev=339031&view=rev
Log:
[Fixed Point Arithmetic] Remove unused include.

lib/Basic cannot depend on lib/AST.

Modified:
cfe/trunk/lib/Basic/FixedPoint.cpp

Modified: cfe/trunk/lib/Basic/FixedPoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FixedPoint.cpp?rev=339031&r1=339030&r2=339031&view=diff
==
--- cfe/trunk/lib/Basic/FixedPoint.cpp (original)
+++ cfe/trunk/lib/Basic/FixedPoint.cpp Mon Aug  6 09:53:21 2018
@@ -12,7 +12,6 @@
 //
 
//===--===//
 
-#include "clang/AST/ASTContext.h"
 #include "clang/Basic/FixedPoint.h"
 
 namespace clang {


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


r332400 - Move helper classes into anonymous namespaces. NFCI.

2018-05-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue May 15 14:26:47 2018
New Revision: 332400

URL: http://llvm.org/viewvc/llvm-project?rev=332400&view=rev
Log:
Move helper classes into anonymous namespaces. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=332400&r1=332399&r2=332400&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue May 15 14:26:47 2018
@@ -1470,9 +1470,10 @@ createConstantGlobalStruct(CodeGenModule
 }
 
 template 
-void createConstantGlobalStructAndAddToParent(CodeGenModule &CGM, QualType Ty,
-  ArrayRef Data,
-  T &Parent) {
+static void
+createConstantGlobalStructAndAddToParent(CodeGenModule &CGM, QualType Ty,
+ ArrayRef Data,
+ T &Parent) {
   const auto *RD = cast(Ty->getAsTagDecl());
   const CGRecordLayout &RL = CGM.getTypes().getCGRecordLayout(RD);
   ConstantStructBuilder Fields = Parent.beginStruct(RL.getLLVMType());

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=332400&r1=332399&r2=332400&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue May 15 14:26:47 2018
@@ -2552,11 +2552,11 @@ void ASTDeclReader::mergeRedeclarable(Re
 /// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
 /// that some types are mergeable during deserialization, otherwise name
 /// lookup fails. This is the case for EnumConstantDecl.
-bool allowODRLikeMergeInC(NamedDecl *ND) {
+static bool allowODRLikeMergeInC(NamedDecl *ND) {
   if (!ND)
 return false;
   // TODO: implement merge for other necessary decls.
-  if (dyn_cast(ND))
+  if (isa(ND))
 return true;
   return false;
 }


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


[clang-tools-extra] r314119 - [clangd] Fix missing "message" key when responding with unsupported method

2017-09-25 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Sep 25 10:16:47 2017
New Revision: 314119

URL: http://llvm.org/viewvc/llvm-project?rev=314119&view=rev
Log:
[clangd] Fix missing "message" key when responding with unsupported method

The language server protocol dictates that a ResponseError should have a
[message string][1] describing the error. This adds a simple message to the
error and a simple test.

[1]: 
https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#response-message

Patch by Raoul Wols!

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

Added:
clang-tools-extra/trunk/test/clangd/unsupported-method.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=314119&r1=314118&r2=314119&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Sep 25 10:16:47 
2017
@@ -42,7 +42,7 @@ void Handler::handleMethod(llvm::yaml::M
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
-  R"(,"error":{"code":-32601}})");
+  R"(,"error":{"code":-32601,"message":"method not found"}})");
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {

Added: clang-tools-extra/trunk/test/clangd/unsupported-method.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/unsupported-method.test?rev=314119&view=auto
==
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test (added)
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test Mon Sep 25 
10:16:47 2017
@@ -0,0 +1,19 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":""}}}
+
+Content-Length: 92
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/jumpInTheAirLikeYouJustDontCare","params":{}}
+# CHECK: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"method not 
found"}}
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}


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


r314391 - Use std::is_trivial instead of is_trivially_copyable.

2017-09-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Sep 28 01:50:30 2017
New Revision: 314391

URL: http://llvm.org/viewvc/llvm-project?rev=314391&view=rev
Log:
Use std::is_trivial instead of is_trivially_copyable.

The oldest versions of GCC we support (before 5) didn't support that
trait. is_trivial is stronger superset that clang::Token fulfills, so
just use that instead.

Modified:
cfe/trunk/lib/Lex/MacroArgs.cpp

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314391&r1=314390&r2=314391&view=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Thu Sep 28 01:50:30 2017
@@ -62,11 +62,11 @@ MacroArgs *MacroArgs::create(const Macro
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
   if (!UnexpArgTokens.empty()) {
-static_assert(std::is_trivially_copyable::value,
+static_assert(std::is_trivial::value,
   "assume trivial copyability if copying into the "
   "uninitialized array (as opposed to reusing a cached "
   "MacroArgs)");
-std::copy(UnexpArgTokens.begin(), UnexpArgTokens.end(), 
+std::copy(UnexpArgTokens.begin(), UnexpArgTokens.end(),
   Result->getTrailingObjects());
   }
 


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


r315185 - Remove unused variables. No functionality change.

2017-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Oct  8 12:11:02 2017
New Revision: 315185

URL: http://llvm.org/viewvc/llvm-project?rev=315185&view=rev
Log:
Remove unused variables. No functionality change.

Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=315185&r1=315184&r2=315185&view=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sun Oct  8 12:11:02 2017
@@ -1169,7 +1169,6 @@ ItaniumRecordLayoutBuilder::LayoutBase(c
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-llvm::DenseMap::iterator Known;
 if (Base->IsVirtual)
   HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
 else

Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=315185&r1=315184&r2=315185&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sun Oct  8 12:11:02 2017
@@ -775,7 +775,6 @@ ComplexPairTy ComplexExprEmitter::EmitBi
   if (!LHSi)
 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
 
-  StringRef LibCallName;
   switch (LHSr->getType()->getTypeID()) {
   default:
 llvm_unreachable("Unsupported floating point type!");

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315185&r1=315184&r2=315185&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun Oct  8 12:11:02 2017
@@ -6886,7 +6886,6 @@ void CGOpenMPRuntime::emitTargetCall(Cod
   for (CapturedStmt::const_capture_iterator CI = CS.capture_begin(),
 CE = CS.capture_end();
CI != CE; ++CI, ++RI, ++CV) {
-StringRef Name;
 QualType Ty;
 
 CurBasePointers.clear();


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


r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Oct  8 13:53:36 2017
New Revision: 315194

URL: http://llvm.org/viewvc/llvm-project?rev=315194&view=rev
Log:
Make SourceLocation, QualType and friends have constexpr constructors.

No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/CharUnits.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/SourceLocation.h

Modified: cfe/trunk/include/clang/AST/CharUnits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=315194&r1=315193&r2=315194&view=diff
==
--- cfe/trunk/include/clang/AST/CharUnits.h (original)
+++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
@@ -40,14 +40,14 @@ namespace clang {
   typedef int64_t QuantityType;
 
 private:
-  QuantityType Quantity;
+  QuantityType Quantity = 0;
 
   explicit CharUnits(QuantityType C) : Quantity(C) {}
 
 public:
 
   /// CharUnits - A default constructor.
-  CharUnits() : Quantity(0) {}
+  CharUnits() = default;
 
   /// Zero - Construct a CharUnits quantity of zero.
   static CharUnits Zero() {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=315194&r1=315193&r2=315194&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
@@ -162,8 +162,6 @@ public:
 FastMask = (1 << FastWidth) - 1
   };
 
-  Qualifiers() : Mask(0) {}
-
   /// Returns the common set of qualifiers while removing them from
   /// the given sets.
   static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R) {
@@ -539,7 +537,7 @@ private:
 
   // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
   //   |C R V|U|GCAttr|Lifetime|AddressSpace|
-  uint32_t Mask;
+  uint32_t Mask = 0;
 
   static const uint32_t UMask = 0x8;
   static const uint32_t UShift = 3;
@@ -634,7 +632,7 @@ class QualType {
 
   friend class QualifierCollector;
 public:
-  QualType() {}
+  QualType() = default;
 
   QualType(const Type *Ptr, unsigned Quals)
 : Value(Ptr, Quals) {}

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=315194&r1=315193&r2=315194&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Sun Oct  8 13:53:36 2017
@@ -39,10 +39,9 @@ class SourceManager;
 class FileID {
   /// \brief A mostly-opaque identifier, where 0 is "invalid", >0 is 
   /// this module, and <-1 is something loaded from another module.
-  int ID;
-public:
-  FileID() : ID(0) {}
+  int ID = 0;
 
+public:
   bool isValid() const { return ID != 0; }
   bool isInvalid() const { return ID == 0; }
 
@@ -86,17 +85,15 @@ private:
 ///
 /// It is important that this type remains small. It is currently 32 bits wide.
 class SourceLocation {
-  unsigned ID;
+  unsigned ID = 0;
   friend class SourceManager;
   friend class ASTReader;
   friend class ASTWriter;
   enum : unsigned {
 MacroIDBit = 1U << 31
   };
-public:
-
-  SourceLocation() : ID(0) {}
 
+public:
   bool isFileID() const  { return (ID & MacroIDBit) == 0; }
   bool isMacroID() const { return (ID & MacroIDBit) != 0; }
 
@@ -198,8 +195,9 @@ inline bool operator<(const SourceLocati
 class SourceRange {
   SourceLocation B;
   SourceLocation E;
+
 public:
-  SourceRange(): B(SourceLocation()), E(SourceLocation()) {}
+  SourceRange() = default;
   SourceRange(SourceLocation loc) : B(loc), E(loc) {}
   SourceRange(SourceLocation begin, SourceLocation end) : B(begin), E(end) {}
 
@@ -230,9 +228,10 @@ public:
 /// range.
 class CharSourceRange { 
   SourceRange Range;
-  bool IsTokenRange;
+  bool IsTokenRange = false;
+
 public:
-  CharSourceRange() : IsTokenRange(false) {}
+  CharSourceRange() = default;
   CharSourceRange(SourceRange R, bool ITR) : Range(R), IsTokenRange(ITR) {}
 
   static CharSourceRange getTokenRange(SourceRange R) {
@@ -330,10 +329,11 @@ class FileEntry;
 ///
 /// This is useful for argument passing to functions that expect both objects.
 class FullSourceLoc : public SourceLocation {
-  const SourceManager *SrcMgr;
+  const SourceManager *SrcMgr = nullptr;
+
 public:
   /// \brief Creates a FullSourceLoc where isValid() returns \c false.
-  explicit FullSourceLoc() : SrcMgr(nullptr) {}
+  FullSourceLoc() = default;
 
   explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
 : SourceLocation(Loc), SrcMgr(&SM) {}


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


r315196 - Remove unused variables. No functionality change.

2017-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Oct  8 14:23:02 2017
New Revision: 315196

URL: http://llvm.org/viewvc/llvm-project?rev=315196&view=rev
Log:
Remove unused variables. No functionality change.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Oct  8 14:23:02 2017
@@ -5671,7 +5671,6 @@ std::string ASTContext::getObjCEncodingF
   // Compute size of all parameters.
   // Start with computing size of a pointer in number of bytes.
   // FIXME: There might(should) be a better way of doing this computation!
-  SourceLocation Loc;
   CharUnits PtrSize = getTypeSizeInChars(VoidPtrTy);
   CharUnits ParmOffset = PtrSize;
   for (auto PI : Decl->parameters()) {
@@ -5779,7 +5778,6 @@ std::string ASTContext::getObjCEncodingF
   // Compute size of all parameters.
   // Start with computing size of a pointer in number of bytes.
   // FIXME: There might(should) be a better way of doing this computation!
-  SourceLocation Loc;
   CharUnits PtrSize = getTypeSizeInChars(VoidPtrTy);
   // The first two arguments (self and _cmd) are pointers; account for
   // their size.

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Sun Oct  8 14:23:02 2017
@@ -3625,7 +3625,6 @@ recurse:
 if (const Expr *Base = PDE->getBase())
   mangleMemberExprBase(Base, PDE->isArrow());
 NestedNameSpecifier *Qualifier = PDE->getQualifier();
-QualType ScopeType;
 if (TypeSourceInfo *ScopeInfo = PDE->getScopeTypeInfo()) {
   if (Qualifier) {
 mangleUnresolvedPrefix(Qualifier,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun Oct  8 14:23:02 2017
@@ -6886,8 +6886,6 @@ void CGOpenMPRuntime::emitTargetCall(Cod
   for (CapturedStmt::const_capture_iterator CI = CS.capture_begin(),
 CE = CS.capture_end();
CI != CE; ++CI, ++RI, ++CV) {
-QualType Ty;
-
 CurBasePointers.clear();
 CurPointers.clear();
 CurSizes.clear();

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sun Oct  8 14:23:02 2017
@@ -1354,7 +1354,6 @@ ExprResult Parser::ParseCXXCasts() {
   if (ExpectAndConsume(tok::greater))
 return ExprError(Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
 
-  SourceLocation LParenLoc, RParenLoc;
   BalancedDelimiterTracker T(*this, tok::l_paren);
 
   if (T.expectAndConsume(diag::err_expected_lparen_after, CastName))

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct  8 14:23:02 2017
@@ -15345,7 +15345,6 @@ EnumConstantDecl *Sema::CheckEnumConstan
 if (Enum->isDependentType() || Val->isTypeDependent())
   EltTy = Context.DependentTy;
 else {
-  SourceLocation ExpLoc;
   if (getLangOpts().CPlusPlus11 && Enum->isFixed() &&
   !getLangOpts().MSVCCompat) {
 // C++11 [dcl.enum]p5: If the underlying type is fixed, [...] the

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=315196&r1=315195&r2=315196&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Oct  8 14:23:02 2017
@@ -6166,7 +6166,6 @@ ExprResult Sema::CheckTemplateArgument(N
 // -- an integral constant-expr

r315197 - Certain versions of clang require an explicit initialization for literal const members.

2017-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Oct  8 14:28:47 2017
New Revision: 315197

URL: http://llvm.org/viewvc/llvm-project?rev=315197&view=rev
Log:
Certain versions of clang require an explicit initialization for literal const 
members.

include/clang/Lex/PreprocessorLexer.h:79:3: error: constructor for
'clang::PreprocessorLexer' must explicitly initialize the const member
'FID'

Modified:
cfe/trunk/include/clang/Lex/PreprocessorLexer.h

Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorLexer.h?rev=315197&r1=315196&r2=315197&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorLexer.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorLexer.h Sun Oct  8 14:28:47 2017
@@ -77,7 +77,7 @@ protected:
   PreprocessorLexer(Preprocessor *pp, FileID fid);
 
   PreprocessorLexer()
-: PP(nullptr), InitialNumSLocEntries(0),
+: PP(nullptr), FID(), InitialNumSLocEntries(0),
   ParsingPreprocessorDirective(false),
   ParsingFilename(false),
   LexingRawMode(false) {}


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


Re: r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-09 Thread Benjamin Kramer via cfe-commits
Looks like a bug in the compiler, the warning doesn't make any sense.
Does creating a FileID() variable and passing that instead work?

On Mon, Oct 9, 2017 at 8:02 PM, Galina Kistanova  wrote:
> Hello Benjamin,
>
> I look s like this commit broke build on one of our builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5327
>
> . . .
> FAILED:
> tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.obj
> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
> -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
> -Itools\clang\include -Iinclude
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
> /DWIN32 /D_WINDOWS   /WX /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4
> -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
> -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
> -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
> -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c-
> /GR- /showIncludes
> /Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
> /Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\clangSerialization.pdb
> /FS -c
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> error C2220: warning treated as error - no 'object' file generated
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> warning C4709: comma operator within array index expression
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Sun, Oct 8, 2017 at 1:53 PM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Sun Oct  8 13:53:36 2017
>> New Revision: 315194
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315194&view=rev
>> Log:
>> Make SourceLocation, QualType and friends have constexpr constructors.
>>
>> No functionality change intended.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/CharUnits.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/Basic/SourceLocation.h
>>
>> Modified: cfe/trunk/include/clang/AST/CharUnits.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=315194&r1=315193&r2=315194&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/CharUnits.h (original)
>> +++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
>> @@ -40,14 +40,14 @@ namespace clang {
>>typedef int64_t QuantityType;
>>
>>  private:
>> -  QuantityType Quantity;
>> +  QuantityType Quantity = 0;
>>
>>explicit CharUnits(QuantityType C) : Quantity(C) {}
>>
>>  public:
>>
>>/// CharUnits - A default constructor.
>> -  CharUnits() : Quantity(0) {}
>> +  CharUnits() = default;
>>
>>/// Zero - Construct a CharUnits quantity of zero.
>>static CharUnits Zero() {
>>
>> Modified: cfe/trunk/include/clang/AST/Type.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=315194&r1=315193&r2=315194&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
>> @@ -162,8 +162,6 @@ public:
>>  FastMask = (1 << FastWidth) - 1
>>};
>>
>> -  Qualifiers() : Mask(0) {}
>> -
>>/// Returns the common set of qualifiers while removing them from
>>/// the given sets.
>>static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
>> {
>> @@ -

r315276 - [ASTMatchers] Don't create a copy of a std::set when iterating over it.

2017-10-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Oct 10 00:21:34 2017
New Revision: 315276

URL: http://llvm.org/viewvc/llvm-project?rev=315276&view=rev
Log:
[ASTMatchers] Don't create a copy of a std::set when iterating over it.

This is a bit awkward because lookup returns a copy instead of a
reference. No functionality change intended.

Modified:
cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=315276&r1=315275&r2=315276&view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Tue Oct 10 00:21:34 2017
@@ -734,7 +734,10 @@ private:
 BoundNodesTreeBuilder *Builder) {
 const Type *const CanonicalType =
   ActiveASTContext->getCanonicalType(TypeNode);
-for (const TypedefNameDecl *Alias : TypeAliases.lookup(CanonicalType)) {
+auto Aliases = TypeAliases.find(CanonicalType);
+if (Aliases == TypeAliases.end())
+  return false;
+for (const TypedefNameDecl *Alias : Aliases->second) {
   BoundNodesTreeBuilder Result(*Builder);
   if (Matcher.matches(*Alias, this, &Result)) {
 *Builder = std::move(Result);


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


[clang-tools-extra] r315277 - [clang-tidy] Use a more efficient map for the virtual near miss check.

2017-10-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Oct 10 00:21:51 2017
New Revision: 315277

URL: http://llvm.org/viewvc/llvm-project?rev=315277&view=rev
Log:
[clang-tidy] Use a more efficient map for the virtual near miss check.

DenseMap performs better here. No functionality change intended.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h?rev=315277&r1=315276&r2=315277&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h Tue Oct 10 
00:21:51 2017
@@ -11,7 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
 
 #include "../ClangTidy.h"
-#include 
+#include "llvm/ADT/DenseMap.h"
 
 namespace clang {
 namespace tidy {
@@ -47,12 +47,12 @@ private:
 
   /// Key: the unique ID of a method.
   /// Value: whether the method is possible to be overridden.
-  std::map PossibleMap;
+  llvm::DenseMap PossibleMap;
 
   /// Key: 
   /// Value: whether the base method is overridden by some method in the 
derived
   /// class.
-  std::map, bool>
+  llvm::DenseMap, bool>
   OverriddenMap;
 
   const unsigned EditDistanceThreshold = 1;


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


r315772 - [Sema] Avoid iterator invalidation when code completing.

2017-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Oct 13 15:14:34 2017
New Revision: 315772

URL: http://llvm.org/viewvc/llvm-project?rev=315772&view=rev
Log:
[Sema] Avoid iterator invalidation when code completing.

It's possible for the code completion consumer to add new decls to the
current scope while lookup happens on it. Avoid this by making a copy
first.

Sadly I wasn't able to get a self-contained test case for this as it
requires code completion + precompiled preamble + the stars aligning to
deserialize at exactly the right time.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=315772&r1=315771&r2=315772&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Oct 13 15:14:34 2017
@@ -3677,8 +3677,10 @@ static void LookupVisibleDecls(Scope *S,
!Visited.alreadyVisitedContext(S->getEntity())) ||
   (S->getEntity())->isFunctionOrMethod()) {
 FindLocalExternScope FindLocals(Result);
-// Walk through the declarations in this Scope.
-for (auto *D : S->decls()) {
+// Walk through the declarations in this Scope. The consumer might add new
+// decls to the scope as part of deserialization, so make a copy first.
+SmallVector ScopeDecls(S->decls().begin(), S->decls().end());
+for (Decl *D : ScopeDecls) {
   if (NamedDecl *ND = dyn_cast(D))
 if ((ND = Result.getAcceptableDecl(ND))) {
   Consumer.FoundDecl(ND, Visited.checkHidden(ND), nullptr, false);


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


r315787 - [Sema] Warn about unused variables if we can constant evaluate the initializer.

2017-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Oct 13 18:30:49 2017
New Revision: 315787

URL: http://llvm.org/viewvc/llvm-project?rev=315787&view=rev
Log:
[Sema] Warn about unused variables if we can constant evaluate the initializer.

If the variable construction can be constant evaluated it doesn't have
side effects, so removing it is always safe. We only try to evaluate
variables that are unused, there should be no impact on compile time.

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315787&r1=315786&r2=315787&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Oct 13 18:30:49 2017
@@ -1723,7 +1723,8 @@ static bool ShouldDiagnoseUnusedDecl(con
 dyn_cast(Init);
   if (Construct && !Construct->isElidable()) {
 CXXConstructorDecl *CD = Construct->getConstructor();
-if (!CD->isTrivial() && !RD->hasAttr())
+if (!CD->isTrivial() && !RD->hasAttr() &&
+!VD->evaluateValue())
   return false;
   }
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315787&r1=315786&r2=315787&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Fri Oct 13 18:30:49 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -194,3 +195,35 @@ void test() {
 }
 
 }
+
+#if __cplusplus >= 201103L
+namespace with_constexpr {
+template 
+struct Literal {
+  T i;
+  Literal() = default;
+  constexpr Literal(T i) : i(i) {}
+};
+
+struct NoLiteral {
+  int i;
+  NoLiteral() = default;
+  constexpr NoLiteral(int i) : i(i) {}
+  ~NoLiteral() {}
+};
+
+static Literal gl1;  // expected-warning {{unused variable 'gl1'}}
+static Literal gl2(1);   // expected-warning {{unused variable 'gl2'}}
+static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}}
+
+template 
+void test(int i) {
+  Literal l1; // expected-warning {{unused variable 'l1'}}
+  Literal l2(42); // expected-warning {{unused variable 'l2'}}
+  Literal l3(i);  // no-warning
+  Literal l4(0);// no-warning
+  NoLiteral nl1;   // no-warning
+  NoLiteral nl2(42);   // no-warning
+}
+}
+#endif


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


[libcxx] r315809 - Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 08:52:38 2017
New Revision: 315809

URL: http://llvm.org/viewvc/llvm-project?rev=315809&view=rev
Log:
Placate unused variable warnings uncovered by improvements to clang's 
-Wunused-variable

Modified:
libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
libcxx/trunk/test/std/numerics/c.math/ctgmath.pass.cpp
libcxx/trunk/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp

Modified: libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -18,4 +18,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -18,6 +18,7 @@
 int main()
 {
 std::complex cd;
+(void)cd;
 double x = sin(1.0);
 (void)x; // to placate scan-build
 }

Modified: 
libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp 
Sat Oct 14 08:52:38 2017
@@ -18,4 +18,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -14,4 +14,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -14,6 +14,7 @@
 int main()
 {
 std::complex cd;
+(void)cd;
 double x = sin(1.0);
 (void)x; // to placate scan-build
 }

Modified: 
libcxx/trunk/test/std/experim

r315811 - Re-land r315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 08:59:34 2017
New Revision: 315811

URL: http://llvm.org/viewvc/llvm-project?rev=315811&view=rev
Log:
Re-land r315787, "[Sema] Warn about unused variables if we can constant 
evaluate the initializer."

The warnings in libc++ tests were fixed in the meantime.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315811&r1=315810&r2=315811&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 14 08:59:34 2017
@@ -1723,7 +1723,8 @@ static bool ShouldDiagnoseUnusedDecl(con
 dyn_cast(Init);
   if (Construct && !Construct->isElidable()) {
 CXXConstructorDecl *CD = Construct->getConstructor();
-if (!CD->isTrivial() && !RD->hasAttr())
+if (!CD->isTrivial() && !RD->hasAttr() &&
+!VD->evaluateValue())
   return false;
   }
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315811&r1=315810&r2=315811&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Sat Oct 14 08:59:34 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -194,3 +195,35 @@ void test() {
 }
 
 }
+
+#if __cplusplus >= 201103L
+namespace with_constexpr {
+template 
+struct Literal {
+  T i;
+  Literal() = default;
+  constexpr Literal(T i) : i(i) {}
+};
+
+struct NoLiteral {
+  int i;
+  NoLiteral() = default;
+  constexpr NoLiteral(int i) : i(i) {}
+  ~NoLiteral() {}
+};
+
+static Literal gl1;  // expected-warning {{unused variable 'gl1'}}
+static Literal gl2(1);   // expected-warning {{unused variable 'gl2'}}
+static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}}
+
+template 
+void test(int i) {
+  Literal l1; // expected-warning {{unused variable 'l1'}}
+  Literal l2(42); // expected-warning {{unused variable 'l2'}}
+  Literal l3(i);  // no-warning
+  Literal l4(0);// no-warning
+  NoLiteral nl1;   // no-warning
+  NoLiteral nl2(42);   // no-warning
+}
+}
+#endif


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


r315845 - [Lex] Remove unused variables. No functionality change.

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 21:27:37 2017
New Revision: 315845

URL: http://llvm.org/viewvc/llvm-project?rev=315845&view=rev
Log:
[Lex] Remove unused variables. No functionality change.

Modified:
cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/VariadicMacroSupport.h?rev=315845&r1=315844&r2=315845&view=diff
==
--- cfe/trunk/include/clang/Lex/VariadicMacroSupport.h (original)
+++ cfe/trunk/include/clang/Lex/VariadicMacroSupport.h Sat Oct 14 21:27:37 2017
@@ -69,8 +69,6 @@ namespace clang {
   /// \brief A class for tracking whether we're inside a VA_OPT during a
   /// traversal of the tokens of a variadic macro definition.
   class VAOptDefinitionContext {
-Preprocessor &PP;
-
 /// Contains all the locations of so far unmatched lparens.
 SmallVector UnmatchedOpeningParens;
 
@@ -79,7 +77,7 @@ namespace clang {
 
   public:
 VAOptDefinitionContext(Preprocessor &PP)
-: PP(PP), Ident__VA_OPT__(PP.Ident__VA_OPT__) {}
+: Ident__VA_OPT__(PP.Ident__VA_OPT__) {}
 
 bool isVAOptToken(const Token &T) const {
   return Ident__VA_OPT__ && T.getIdentifierInfo() == Ident__VA_OPT__;

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=315845&r1=315844&r2=315845&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Sat Oct 14 21:27:37 2017
@@ -184,18 +184,12 @@ void TokenLexer::stringifyVAOPTContents(
   // Perform token pasting (concatenation) prior to stringization.
   for (unsigned int CurTokenIdx = 0; CurTokenIdx != NumVAOptTokens;
++CurTokenIdx) {
-const unsigned int PrevTokenIdx = CurTokenIdx;
-
 if (VAOPTTokens[CurTokenIdx].is(tok::hashhash)) {
   assert(CurTokenIdx != 0 &&
  "Can not have __VAOPT__ contents begin with a ##");
   Token &LHS = VAOPTTokens[CurTokenIdx - 1];
   pasteTokens(LHS, llvm::makeArrayRef(VAOPTTokens, NumVAOptTokens),
   CurTokenIdx);
-  // CurTokenIdx is either the same as NumTokens or one past the
-  // last token concatenated.
-  // PrevTokenIdx is the index of the hashhash
-  const unsigned NumTokensPastedTogether = CurTokenIdx - PrevTokenIdx + 1;
   // Replace the token prior to the first ## in this iteration.
   ConcatenatedVAOPTResultToks.back() = LHS;
   if (CurTokenIdx == NumVAOptTokens)


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


r316127 - [Driver] Fix use after free in Hexagon toolchain code.

2017-10-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Oct 18 14:43:42 2017
New Revision: 316127

URL: http://llvm.org/viewvc/llvm-project?rev=316127&view=rev
Log:
[Driver] Fix use after free in Hexagon toolchain code.

No functionality change intended.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=316127&r1=316126&r2=316127&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Oct 18 14:43:42 2017
@@ -28,8 +28,8 @@ using namespace clang;
 using namespace llvm::opt;
 
 // Default hvx-length for various versions.
-static std::string getDefaultHvxLength(const StringRef &Cpu) {
-  return llvm::StringSwitch(Cpu)
+static StringRef getDefaultHvxLength(StringRef Cpu) {
+  return llvm::StringSwitch(Cpu)
   .Case("v60", "64b")
   .Case("v62", "64b")
   .Default("128b");
@@ -93,7 +93,7 @@ static void handleHVXTargetFeatures(cons
   }
   // Default hvx-length based on Cpu.
   else if (HasHVX)
-HVXLength = StringRef(getDefaultHvxLength(Cpu));
+HVXLength = getDefaultHvxLength(Cpu);
 
   if (!HVXLength.empty()) {
 HVXFeature =


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


Re: r315811 - Re-land r315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."

2017-10-19 Thread Benjamin Kramer via cfe-commits
We should check VD->getInit()->isValueDependent() before we call
evaluateValue. I wasn't able to come up with a test case that triggers
the assert though :(

On Thu, Oct 19, 2017 at 5:45 PM, Alexander Kornienko  wrote:
>
>
> On Sat, Oct 14, 2017 at 5:59 PM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Sat Oct 14 08:59:34 2017
>> New Revision: 315811
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315811&view=rev
>> Log:
>> Re-land r315787, "[Sema] Warn about unused variables if we can constant
>> evaluate the initializer."
>>
>> The warnings in libc++ tests were fixed in the meantime.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315811&r1=315810&r2=315811&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 14 08:59:34 2017
>> @@ -1723,7 +1723,8 @@ static bool ShouldDiagnoseUnusedDecl(con
>>  dyn_cast(Init);
>>if (Construct && !Construct->isElidable()) {
>>  CXXConstructorDecl *CD = Construct->getConstructor();
>> -if (!CD->isTrivial() && !RD->hasAttr())
>> +if (!CD->isTrivial() && !RD->hasAttr() &&
>> +!VD->evaluateValue())
>
>
> The evaluateValue call above causes an assertion failure on
> instantiation-dependent values:
> llvm/tools/clang/lib/AST/Decl.cpp:2196 in clang::APValue
> *clang::VarDecl::evaluateValue(SmallVectorImpl
> &) const: !Init->isValueDependent()
>
> I'm not sure why evaluateValue uses an assertion instead of outputting a
> note and returning nullptr, but the assertion can be avoided on the caller
> site as well.
>
> Working on a reduced test case...
>
>>
>>return false;
>>}
>>  }
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315811&r1=315810&r2=315811&view=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Sat Oct 14 08:59:34
>> 2017
>> @@ -1,4 +1,5 @@
>>  // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label
>> -Wno-c++1y-extensions -verify %s
>> +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label
>> -Wno-c++1y-extensions -verify -std=c++11 %s
>>  template void f() {
>>T t;
>>t = 17;
>> @@ -194,3 +195,35 @@ void test() {
>>  }
>>
>>  }
>> +
>> +#if __cplusplus >= 201103L
>> +namespace with_constexpr {
>> +template 
>> +struct Literal {
>> +  T i;
>> +  Literal() = default;
>> +  constexpr Literal(T i) : i(i) {}
>> +};
>> +
>> +struct NoLiteral {
>> +  int i;
>> +  NoLiteral() = default;
>> +  constexpr NoLiteral(int i) : i(i) {}
>> +  ~NoLiteral() {}
>> +};
>> +
>> +static Literal gl1;  // expected-warning {{unused variable
>> 'gl1'}}
>> +static Literal gl2(1);   // expected-warning {{unused variable
>> 'gl2'}}
>> +static const Literal gl3(0); // expected-warning {{unused variable
>> 'gl3'}}
>> +
>> +template 
>> +void test(int i) {
>> +  Literal l1; // expected-warning {{unused variable 'l1'}}
>> +  Literal l2(42); // expected-warning {{unused variable 'l2'}}
>> +  Literal l3(i);  // no-warning
>> +  Literal l4(0);// no-warning
>> +  NoLiteral nl1;   // no-warning
>> +  NoLiteral nl2(42);   // no-warning
>> +}
>> +}
>> +#endif
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316177 - [Sema] Fix assertion failure when checking for unused variables in a dependent context.

2017-10-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 19 12:07:13 2017
New Revision: 316177

URL: http://llvm.org/viewvc/llvm-project?rev=316177&view=rev
Log:
[Sema] Fix assertion failure when checking for unused variables in a dependent 
context.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=316177&r1=316176&r2=316177&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 19 12:07:13 2017
@@ -1724,7 +1724,7 @@ static bool ShouldDiagnoseUnusedDecl(con
   if (Construct && !Construct->isElidable()) {
 CXXConstructorDecl *CD = Construct->getConstructor();
 if (!CD->isTrivial() && !RD->hasAttr() &&
-!VD->evaluateValue())
+(VD->getInit()->isValueDependent() || !VD->evaluateValue()))
   return false;
   }
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=316177&r1=316176&r2=316177&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Thu Oct 19 12:07:13 2017
@@ -226,4 +226,14 @@ void test(int i) {
   NoLiteral nl2(42);   // no-warning
 }
 }
+
+namespace crash {
+struct a {
+  a(const char *);
+};
+template 
+void c() {
+  a d(b::e ? "" : "");
+}
+}
 #endif


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


Re: r315811 - Re-land r315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."

2017-10-19 Thread Benjamin Kramer via cfe-commits
Fixed in r316177.

On Thu, Oct 19, 2017 at 5:57 PM, Benjamin Kramer  wrote:
> We should check VD->getInit()->isValueDependent() before we call
> evaluateValue. I wasn't able to come up with a test case that triggers
> the assert though :(
>
> On Thu, Oct 19, 2017 at 5:45 PM, Alexander Kornienko  
> wrote:
>>
>>
>> On Sat, Oct 14, 2017 at 5:59 PM, Benjamin Kramer via cfe-commits
>>  wrote:
>>>
>>> Author: d0k
>>> Date: Sat Oct 14 08:59:34 2017
>>> New Revision: 315811
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=315811&view=rev
>>> Log:
>>> Re-land r315787, "[Sema] Warn about unused variables if we can constant
>>> evaluate the initializer."
>>>
>>> The warnings in libc++ tests were fixed in the meantime.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315811&r1=315810&r2=315811&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 14 08:59:34 2017
>>> @@ -1723,7 +1723,8 @@ static bool ShouldDiagnoseUnusedDecl(con
>>>  dyn_cast(Init);
>>>if (Construct && !Construct->isElidable()) {
>>>  CXXConstructorDecl *CD = Construct->getConstructor();
>>> -if (!CD->isTrivial() && !RD->hasAttr())
>>> +if (!CD->isTrivial() && !RD->hasAttr() &&
>>> +!VD->evaluateValue())
>>
>>
>> The evaluateValue call above causes an assertion failure on
>> instantiation-dependent values:
>> llvm/tools/clang/lib/AST/Decl.cpp:2196 in clang::APValue
>> *clang::VarDecl::evaluateValue(SmallVectorImpl
>> &) const: !Init->isValueDependent()
>>
>> I'm not sure why evaluateValue uses an assertion instead of outputting a
>> note and returning nullptr, but the assertion can be avoided on the caller
>> site as well.
>>
>> Working on a reduced test case...
>>
>>>
>>>return false;
>>>}
>>>  }
>>>
>>> Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315811&r1=315810&r2=315811&view=diff
>>>
>>> ==
>>> --- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
>>> +++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Sat Oct 14 08:59:34
>>> 2017
>>> @@ -1,4 +1,5 @@
>>>  // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label
>>> -Wno-c++1y-extensions -verify %s
>>> +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label
>>> -Wno-c++1y-extensions -verify -std=c++11 %s
>>>  template void f() {
>>>T t;
>>>t = 17;
>>> @@ -194,3 +195,35 @@ void test() {
>>>  }
>>>
>>>  }
>>> +
>>> +#if __cplusplus >= 201103L
>>> +namespace with_constexpr {
>>> +template 
>>> +struct Literal {
>>> +  T i;
>>> +  Literal() = default;
>>> +  constexpr Literal(T i) : i(i) {}
>>> +};
>>> +
>>> +struct NoLiteral {
>>> +  int i;
>>> +  NoLiteral() = default;
>>> +  constexpr NoLiteral(int i) : i(i) {}
>>> +  ~NoLiteral() {}
>>> +};
>>> +
>>> +static Literal gl1;  // expected-warning {{unused variable
>>> 'gl1'}}
>>> +static Literal gl2(1);   // expected-warning {{unused variable
>>> 'gl2'}}
>>> +static const Literal gl3(0); // expected-warning {{unused variable
>>> 'gl3'}}
>>> +
>>> +template 
>>> +void test(int i) {
>>> +  Literal l1; // expected-warning {{unused variable 'l1'}}
>>> +  Literal l2(42); // expected-warning {{unused variable 'l2'}}
>>> +  Literal l3(i);  // no-warning
>>> +  Literal l4(0);// no-warning
>>> +  NoLiteral nl1;   // no-warning
>>> +  NoLiteral nl2(42);   // no-warning
>>> +}
>>> +}
>>> +#endif
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316301 - Create fewer copies of StringMaps. No functionality change intended.

2017-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Oct 22 13:16:28 2017
New Revision: 316301

URL: http://llvm.org/viewvc/llvm-project?rev=316301&view=rev
Log:
Create fewer copies of StringMaps. No functionality change intended.

Modified:
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=316301&r1=316300&r2=316301&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Sun Oct 22 13:16:28 2017
@@ -445,7 +445,7 @@ PrecompiledPreamble::PrecompiledPreamble
 TempPCHFile PCHFile, std::vector PreambleBytes,
 bool PreambleEndsAtStartOfLine,
 llvm::StringMap FilesInPreamble)
-: PCHFile(std::move(PCHFile)), FilesInPreamble(FilesInPreamble),
+: PCHFile(std::move(PCHFile)), FilesInPreamble(std::move(FilesInPreamble)),
   PreambleBytes(std::move(PreambleBytes)),
   PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
 

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=316301&r1=316300&r2=316301&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Sun Oct 22 13:16:28 2017
@@ -558,7 +558,7 @@ StmtResult Parser::ParseMicrosoftAsmStat
   if (buildMSAsmString(PP, AsmLoc, AsmToks, TokOffsets, AsmString))
 return StmtError();
 
-  TargetOptions TO = Actions.Context.getTargetInfo().getTargetOpts();
+  const TargetOptions &TO = Actions.Context.getTargetInfo().getTargetOpts();
   std::string FeaturesStr =
   llvm::join(TO.Features.begin(), TO.Features.end(), ",");
 


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


r316344 - [ASTMatchers] Expose forEachOverriden in dynamic AST matchers.

2017-10-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct 23 09:48:46 2017
New Revision: 316344

URL: http://llvm.org/viewvc/llvm-project?rev=316344&view=rev
Log:
[ASTMatchers] Expose forEachOverriden in dynamic AST matchers.

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=316344&r1=316343&r2=316344&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct 23 09:48:46 2017
@@ -196,6 +196,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forFunction);


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


[clang-tools-extra] r341643 - [clang-tidy] Abseil: Allow macros inside of absl to use internal absl things

2018-09-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Sep  7 02:25:23 2018
New Revision: 341643

URL: http://llvm.org/viewvc/llvm-project?rev=341643&view=rev
Log:
[clang-tidy] Abseil: Allow macros inside of absl to use internal absl things

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h
clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h?rev=341643&r1=341642&r2=341643&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h Fri Sep  7 
02:25:23 2018
@@ -33,7 +33,7 @@ AST_POLYMORPHIC_MATCHER(
 isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
 NestedNameSpecifierLoc)) {
   auto &SourceManager = Finder->getASTContext().getSourceManager();
-  SourceLocation Loc = Node.getBeginLoc();
+  SourceLocation Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
   if (Loc.isInvalid())
 return false;
   const FileEntry *FileEntry =

Modified: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h?rev=341643&r1=341642&r2=341643&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h 
Fri Sep  7 02:25:23 2018
@@ -31,3 +31,5 @@ class FriendUsageInternal {
 namespace absl {
 void OpeningNamespaceInternally() { strings_internal::InternalFunction(); }
 } // namespace absl
+
+#define USE_INTERNAL(x) absl::strings_internal::Internal##x()

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp?rev=341643&r1=341642&r2=341643&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp 
Fri Sep  7 02:25:23 2018
@@ -37,3 +37,11 @@ namespace absl {
 SomeContainer b;
 std::string Str = absl::StringsFunction("a");
 } // namespace absl
+
+#define USE_EXTERNAL(x) absl::strings_internal::Internal##x()
+
+void MacroUse() {
+  USE_INTERNAL(Function); // no-warning
+  USE_EXTERNAL(Function);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' 
namespaces; those implementation details are reserved to Abseil
+}


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


[clang-tools-extra] r341925 - [clang-tidy] Add a missing comma after "flags"

2018-09-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Sep 11 03:37:08 2018
New Revision: 341925

URL: http://llvm.org/viewvc/llvm-project?rev=341925&view=rev
Log:
[clang-tidy] Add a missing comma after "flags"

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/internal-file.h
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h
clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h?rev=341925&r1=341924&r2=341925&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h Tue Sep 11 
03:37:08 2018
@@ -43,24 +43,15 @@ AST_POLYMORPHIC_MATCHER(
   // Determine whether filepath contains "absl/[absl-library]" substring, where
   // [absl-library] is AbseilLibraries list entry.
   StringRef Path = FileEntry->getName();
-  const static llvm::SmallString<5> AbslPrefix("absl/");
+  static constexpr llvm::StringLiteral AbslPrefix("absl/");
   size_t PrefixPosition = Path.find(AbslPrefix);
   if (PrefixPosition == StringRef::npos)
 return false;
   Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
-  static const char *AbseilLibraries[] = {"algorithm",
-  "base",
-  "container",
-  "debugging",
-  "flags"
-  "memory",
-  "meta",
-  "numeric",
-  "strings",
-  "synchronization",
-  "time",
-  "types",
-  "utility"};
+  static const char *AbseilLibraries[] = {
+  "algorithm", "base",  "container", "debugging", "flags",
+  "memory","meta",  "numeric",   "strings",   "synchronization",
+  "time",  "types", "utility"};
   return std::any_of(
   std::begin(AbseilLibraries), std::end(AbseilLibraries),
   [&](const char *Library) { return Path.startswith(Library); });

Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/internal-file.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/internal-file.h?rev=341925&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/internal-file.h 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/flags/internal-file.h 
Tue Sep 11 03:37:08 2018
@@ -0,0 +1 @@
+#define USE_INTERNAL(x) absl::strings_internal::Internal##x()

Modified: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h?rev=341925&r1=341924&r2=341925&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h 
Tue Sep 11 03:37:08 2018
@@ -31,5 +31,3 @@ class FriendUsageInternal {
 namespace absl {
 void OpeningNamespaceInternally() { strings_internal::InternalFunction(); }
 } // namespace absl
-
-#define USE_INTERNAL(x) absl::strings_internal::Internal##x()

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp?rev=341925&r1=341924&r2=341925&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp 
Tue Sep 11 03:37:08 2018
@@ -2,6 +2,7 @@
 // RUN: clang-tidy -checks='-*, abseil-no-internal-dependencies' 
-header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
 
 #include "absl/strings/internal-file.h"
+#include "absl/flags/internal-file.h"
 // CHECK-NOT: warning:
 
 #include "absl/external-file.h"


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


[clang-tools-extra] r341929 - [clang-tidy] Insert absl::StrAppend when replacing StrCat.

2018-09-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Sep 11 05:19:45 2018
New Revision: 341929

URL: http://llvm.org/viewvc/llvm-project?rev=341929&view=rev
Log:
[clang-tidy] Insert absl::StrAppend when replacing StrCat.

There might be no using decl for StrAppend around, inserting the
qualified name is less likely to break things.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp?rev=341929&r1=341928&r2=341929&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp Tue Sep 11 
05:19:45 2018
@@ -93,7 +93,7 @@ void StrCatAppendCheck::check(const Matc
   << FixItHint::CreateReplacement(
  CharSourceRange::getTokenRange(Op->getBeginLoc(),
 Call->getCallee()->getEndLoc()),
- "StrAppend")
+ "absl::StrAppend")
   << FixItHint::CreateInsertion(Call->getArg(0)->getBeginLoc(), "&");
 }
 

Modified: clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp?rev=341929&r1=341928&r2=341929&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp Tue Sep 
11 05:19:45 2018
@@ -97,7 +97,7 @@ void Bar() {
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: call to 'absl::StrCat' has no 
effect
   A = StrCat(A, B);
 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 
'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}}  StrAppend(&A, B);
+// CHECK-FIXES: {{^}}  absl::StrAppend(&A, B);
   B = StrCat(A, B);
 
 #define M(X) X = StrCat(X, A)
@@ -117,13 +117,13 @@ void OutsideAbsl() {
   std::string A, B;
   A = absl::StrCat(A, B);
 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 
'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}}  StrAppend(&A, B);
+// CHECK-FIXES: {{^}}  absl::StrAppend(&A, B);
 }
 
-void OutisdeUsingAbsl() {
+void OutsideUsingAbsl() {
   std::string A, B;
   using absl::StrCat;
   A = StrCat(A, B);
 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 
'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}}  StrAppend(&A, B);
+// CHECK-FIXES: {{^}}  absl::StrAppend(&A, B);
 }


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


[clang-tools-extra] r342041 - [clang-tidy] Abseil: Add more directories that are slated for future absl expansion.

2018-09-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Sep 12 03:04:16 2018
New Revision: 342041

URL: http://llvm.org/viewvc/llvm-project?rev=342041&view=rev
Log:
[clang-tidy] Abseil: Add more directories that are slated for future absl 
expansion.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h?rev=342041&r1=342040&r2=342041&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h Wed Sep 12 
03:04:16 2018
@@ -49,9 +49,10 @@ AST_POLYMORPHIC_MATCHER(
 return false;
   Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
   static const char *AbseilLibraries[] = {
-  "algorithm", "base",  "container", "debugging", "flags",
-  "memory","meta",  "numeric",   "strings",   "synchronization",
-  "time",  "types", "utility"};
+  "algorithm", "base", "container",   "debugging", "flags",
+  "hash",  "iterator", "memory",  "meta",  "numeric",
+  "random","strings",  "synchronization", "time",  "types",
+  "utility"};
   return std::any_of(
   std::begin(AbseilLibraries), std::end(AbseilLibraries),
   [&](const char *Library) { return Path.startswith(Library); });


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


[clang-tools-extra] r342252 - [modernize-use-transparent-functors] TypeLocs can be implicitly created, don't crash when encountering those.

2018-09-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Sep 14 11:05:30 2018
New Revision: 342252

URL: http://llvm.org/viewvc/llvm-project?rev=342252&view=rev
Log:
[modernize-use-transparent-functors] TypeLocs can be implicitly created, don't 
crash when encountering those.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp?rev=342252&r1=342251&r2=342252&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp 
Fri Sep 14 11:05:30 2018
@@ -121,6 +121,8 @@ void UseTransparentFunctorsCheck::check(
 return;
 
   SourceLocation ReportLoc = FunctorLoc.getLocation();
+  if (ReportLoc.isInvalid())
+return;
   diag(ReportLoc, Message) << (FuncClass->getName() + "<>").str()
<< FixItHint::CreateRemoval(
   
FunctorTypeLoc.getArgLoc(0).getSourceRange());

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp?rev=342252&r1=342251&r2=342252&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp 
Fri Sep 14 11:05:30 2018
@@ -104,4 +104,7 @@ int main() {
   std::set2 control;
 }
 
-
+struct ImplicitTypeLoc : std::set2> {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: prefer transparent functors
+  ImplicitTypeLoc() {}
+};


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


[clang-tools-extra] r337601 - [clangd] Fix racy use-after-scope in unittest

2018-07-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jul 20 11:45:25 2018
New Revision: 337601

URL: http://llvm.org/viewvc/llvm-project?rev=337601&view=rev
Log:
[clangd] Fix racy use-after-scope in unittest

This only shows up with asan when the stars align in a bad way.

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

Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=337601&r1=337600&r2=337601&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Fri Jul 20 
11:45:25 2018
@@ -251,6 +251,7 @@ TEST_F(TUSchedulerTests, ManyUpdates) {
 }
 
 TEST_F(TUSchedulerTests, EvictedAST) {
+  std::atomic BuiltASTCounter(0);
   ASTRetentionPolicy Policy;
   Policy.MaxRetainedASTs = 2;
   TUScheduler S(
@@ -267,8 +268,6 @@ TEST_F(TUSchedulerTests, EvictedAST) {
   auto Bar = testPath("bar.cpp");
   auto Baz = testPath("baz.cpp");
 
-  std::atomic BuiltASTCounter;
-  BuiltASTCounter = false;
   // Build one file in advance. We will not access it later, so it will be the
   // one that the cache will evict.
   S.update(Foo, getInputs(Foo, SourceContents), WantDiagnostics::Yes,


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


r337607 - [AST] Various micro-optimizations in CXXInheritance

2018-07-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jul 20 13:13:08 2018
New Revision: 337607

URL: http://llvm.org/viewvc/llvm-project?rev=337607&view=rev
Log:
[AST] Various micro-optimizations in CXXInheritance

1. Pack std::pair in CXXBasePaths::ClassSubobjects.
2. Use a SmallPtrSet instead of a SmallDenseSet for 
CXXBasePaths::VisitedDependentRecords.
3. Reorder some members of CXXBasePaths to save 8 bytes.
4. Use a SmallSetVector instead of a SetVector in 
CXXBasePaths::ComputeDeclsFound to avoid some allocations.

This speeds up an -fsyntax-only on all of Boost by approx 0.15%,
mainly by speeding up CXXBasePaths::lookupInBases by
approx 10%. No functional changes.

Patch by Bruno Ricci!

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

Modified:
cfe/trunk/include/clang/AST/CXXInheritance.h
cfe/trunk/lib/AST/CXXInheritance.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=337607&r1=337606&r2=337607&view=diff
==
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Fri Jul 20 13:13:08 2018
@@ -125,18 +125,36 @@ class CXXBasePaths {
   /// Paths - The actual set of paths that can be taken from the
   /// derived class to the same base class.
   std::list Paths;
-  
+
   /// ClassSubobjects - Records the class subobjects for each class
-  /// type that we've seen. The first element in the pair says
+  /// type that we've seen. The first element IsVirtBase says
   /// whether we found a path to a virtual base for that class type,
-  /// while the element contains the number of non-virtual base
+  /// while NumberOfNonVirtBases contains the number of non-virtual base
   /// class subobjects for that class type. The key of the map is
   /// the cv-unqualified canonical type of the base class subobject.
-  llvm::SmallDenseMap, 8> ClassSubobjects;
+  struct IsVirtBaseAndNumberNonVirtBases {
+unsigned IsVirtBase : 1;
+unsigned NumberOfNonVirtBases : 31;
+  };
+  llvm::SmallDenseMap
+  ClassSubobjects;
 
   /// VisitedDependentRecords - Records the dependent records that have been
   /// already visited.
-  llvm::SmallDenseSet VisitedDependentRecords;
+  llvm::SmallPtrSet VisitedDependentRecords;
+
+  /// DetectedVirtual - The base class that is virtual.
+  const RecordType *DetectedVirtual = nullptr;
+
+  /// ScratchPath - A BasePath that is used by Sema::lookupInBases
+  /// to help build the set of paths.
+  CXXBasePath ScratchPath;
+
+  /// Array of the declarations that have been found. This
+  /// array is constructed only if needed, e.g., to iterate over the
+  /// results within LookupResult.
+  std::unique_ptr DeclsFound;
+  unsigned NumDeclsFound = 0;
 
   /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find
   /// ambiguous paths while it is looking for a path from a derived
@@ -152,20 +170,7 @@ class CXXBasePaths {
   /// if it finds a path that goes across a virtual base. The virtual class
   /// is also recorded.
   bool DetectVirtual;
-  
-  /// ScratchPath - A BasePath that is used by Sema::lookupInBases
-  /// to help build the set of paths.
-  CXXBasePath ScratchPath;
 
-  /// DetectedVirtual - The base class that is virtual.
-  const RecordType *DetectedVirtual = nullptr;
-  
-  /// Array of the declarations that have been found. This
-  /// array is constructed only if needed, e.g., to iterate over the
-  /// results within LookupResult.
-  std::unique_ptr DeclsFound;
-  unsigned NumDeclsFound = 0;
-  
   void ComputeDeclsFound();
 
   bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record,

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=337607&r1=337606&r2=337607&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Fri Jul 20 13:13:08 2018
@@ -40,7 +40,7 @@ void CXXBasePaths::ComputeDeclsFound() {
   assert(NumDeclsFound == 0 && !DeclsFound &&
  "Already computed the set of declarations");
 
-  llvm::SetVector> Decls;
+  llvm::SmallSetVector Decls;
   for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path)
 Decls.insert(Path->Decls.front());
 
@@ -63,8 +63,8 @@ CXXBasePaths::decl_range CXXBasePaths::f
 /// an unqualified, canonical class type.
 bool CXXBasePaths::isAmbiguous(CanQualType BaseType) {
   BaseType = BaseType.getUnqualifiedType();
-  std::pair& Subobjects = ClassSubobjects[BaseType];
-  return Subobjects.second + (Subobjects.first? 1 : 0) > 1;
+  IsVirtBaseAndNumberNonVirtBases Subobjects = ClassSubobjects[BaseType];
+  return Subobjects.NumberOfNonVirtBases + (Subobjects.IsVirtBase ? 1 : 0) > 1;
 }
 
 /// clear - Clear out all prior path information.
@@ -217,21 +217,21 @@ bool CXXBasePa

[clang-tools-extra] r337655 - [clangd] Unbreak fuzzer build.

2018-07-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Jul 22 08:55:57 2018
New Revision: 337655

URL: http://llvm.org/viewvc/llvm-project?rev=337655&view=rev
Log:
[clangd] Unbreak fuzzer build.

Modified:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp

Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=337655&r1=337654&r2=337655&view=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Sun Jul 22 08:55:57 
2018
@@ -20,7 +20,8 @@
 #include 
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
-  clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(), nullptr);
+  clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(),
+clang::clangd::Logger::Error, nullptr);
   clang::clangd::CodeCompleteOptions CCOpts;
   CCOpts.EnableSnippets = false;
   clang::clangd::ClangdServer::Options Opts;


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


r337688 - [AST] Use llvm::TrailingObjects in CXXTryStmt

2018-07-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Jul 23 05:45:24 2018
New Revision: 337688

URL: http://llvm.org/viewvc/llvm-project?rev=337688&view=rev
Log:
[AST] Use llvm::TrailingObjects in CXXTryStmt

1. Use llvm::TrailingObjects in CXXTryStmt instead of manually doing the 
reinterpret_casts + pointer arithmetic. This is more consistent with other 
classes using this idiom and this make it clearer that this class has trailing 
objects.
2. Make the class CXXTryStmt final since it has trailing objects.
3. Move the friend declarations together.

No functional changes.

Patch by Bruno Ricci!

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

Modified:
cfe/trunk/include/clang/AST/StmtCXX.h
cfe/trunk/lib/AST/StmtCXX.cpp

Modified: cfe/trunk/include/clang/AST/StmtCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=337688&r1=337687&r2=337688&view=diff
==
--- cfe/trunk/include/clang/AST/StmtCXX.h (original)
+++ cfe/trunk/include/clang/AST/StmtCXX.h Mon Jul 23 05:45:24 2018
@@ -62,21 +62,22 @@ public:
 
 /// CXXTryStmt - A C++ try block, including all handlers.
 ///
-class CXXTryStmt : public Stmt {
+class CXXTryStmt final : public Stmt,
+ private llvm::TrailingObjects {
+
+  friend TrailingObjects;
+  friend class ASTStmtReader;
+
   SourceLocation TryLoc;
   unsigned NumHandlers;
+  size_t numTrailingObjects(OverloadToken) const { return NumHandlers; 
}
 
   CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, ArrayRef handlers);
-
   CXXTryStmt(EmptyShell Empty, unsigned numHandlers)
 : Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
 
-  Stmt const * const *getStmts() const {
-return reinterpret_cast(this + 1);
-  }
-  Stmt **getStmts() {
-return reinterpret_cast(this + 1);
-  }
+  Stmt *const *getStmts() const { return getTrailingObjects(); }
+  Stmt **getStmts() { return getTrailingObjects(); }
 
 public:
   static CXXTryStmt *Create(const ASTContext &C, SourceLocation tryLoc,
@@ -115,8 +116,6 @@ public:
   child_range children() {
 return child_range(getStmts(), getStmts() + getNumHandlers() + 1);
   }
-
-  friend class ASTStmtReader;
 };
 
 /// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for

Modified: cfe/trunk/lib/AST/StmtCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtCXX.cpp?rev=337688&r1=337687&r2=337688&view=diff
==
--- cfe/trunk/lib/AST/StmtCXX.cpp (original)
+++ cfe/trunk/lib/AST/StmtCXX.cpp Mon Jul 23 05:45:24 2018
@@ -25,18 +25,14 @@ QualType CXXCatchStmt::getCaughtType() c
 
 CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, SourceLocation tryLoc,
Stmt *tryBlock, ArrayRef handlers) {
-  std::size_t Size = sizeof(CXXTryStmt);
-  Size += ((handlers.size() + 1) * sizeof(Stmt *));
-
+  const size_t Size = totalSizeToAlloc(handlers.size() + 1);
   void *Mem = C.Allocate(Size, alignof(CXXTryStmt));
   return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers);
 }
 
 CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, EmptyShell Empty,
unsigned numHandlers) {
-  std::size_t Size = sizeof(CXXTryStmt);
-  Size += ((numHandlers + 1) * sizeof(Stmt *));
-
+  const size_t Size = totalSizeToAlloc(numHandlers + 1);
   void *Mem = C.Allocate(Size, alignof(CXXTryStmt));
   return new (Mem) CXXTryStmt(Empty, numHandlers);
 }
@@ -44,7 +40,7 @@ CXXTryStmt *CXXTryStmt::Create(const AST
 CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
ArrayRef handlers)
 : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
-  Stmt **Stmts = reinterpret_cast(this + 1);
+  Stmt **Stmts = getStmts();
   Stmts[0] = tryBlock;
   std::copy(handlers.begin(), handlers.end(), Stmts + 1);
 }


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


[clang-tools-extra] r337860 - [clangd] Guard fuzzer against empty inputs.

2018-07-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Jul 24 14:50:06 2018
New Revision: 337860

URL: http://llvm.org/viewvc/llvm-project?rev=337860&view=rev
Log:
[clangd] Guard fuzzer against empty inputs.

Modified:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp

Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=337860&r1=337859&r2=337860&view=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Tue Jul 24 14:50:06 
2018
@@ -20,6 +20,9 @@
 #include 
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  if (size == 0)
+return 0;
+
   clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(),
 clang::clangd::Logger::Error, nullptr);
   clang::clangd::CodeCompleteOptions CCOpts;


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


r337862 - [Sema] Destroy tokens in DeclaratorChunk params

2018-07-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Jul 24 15:47:16 2018
New Revision: 337862

URL: http://llvm.org/viewvc/llvm-project?rev=337862&view=rev
Log:
[Sema] Destroy tokens in DeclaratorChunk params

Otherwise this leaks in some edge cases.

Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=337862&r1=337861&r2=337862&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Jul 24 15:47:16 2018
@@ -1355,8 +1355,7 @@ struct DeclaratorChunk {
 }
 
 void destroy() {
-  if (DeleteParams)
-delete[] Params;
+  freeParams();
   switch (getExceptionSpecType()) {
   default:
 break;


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


Re: r338299 - [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Benjamin Kramer via cfe-commits
On Mon, Jul 30, 2018 at 10:37 PM Scott Linder via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: scott.linder
> Date: Mon Jul 30 13:31:11 2018
> New Revision: 338299
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338299&view=rev
> Log:
> [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
>
> OpenCL block literal structs have different fields which are now correctly
> identified in the debug info.
>
> Differential Revision: https://reviews.llvm.org/D49930
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/test/CodeGenOpenCL/blocks.cl
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338299&r1=338298&r2=338299&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 13:31:11 2018
> @@ -971,20 +971,25 @@ llvm::DIType *CGDebugInfo::CreateType(co
>auto *DescTy = DBuilder.createPointerType(EltTy, Size);
>
>FieldOffset = 0;
> -  FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> -  EltTys.push_back(CreateMemberType(Unit, FType, "__isa", &FieldOffset));
> -  FType = CGM.getContext().IntTy;
> -  EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
> &FieldOffset));
> -  EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
> &FieldOffset));
> -  FType = CGM.getContext().getPointerType(Ty->getPointeeType());
> -  EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
> &FieldOffset));
> -
> -  FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> -  FieldSize = CGM.getContext().getTypeSize(Ty);
> -  FieldAlign = CGM.getContext().getTypeAlign(Ty);
> -  EltTys.push_back(DBuilder.createMemberType(
> -  Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
> FieldOffset,
> -  llvm::DINode::FlagZero, DescTy));
> +  if (CGM.getLangOpts().OpenCL) {
> +FType = CGM.getContext().IntTy;
> +EltTys.push_back(CreateMemberType(Unit, FType, "__size",
> &FieldOffset));
> +EltTys.push_back(CreateMemberType(Unit, FType, "__align",
> &FieldOffset));
> +  } else {
> +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> +EltTys.push_back(CreateMemberType(Unit, FType, "__isa",
> &FieldOffset));
> +FType = CGM.getContext().IntTy;
> +EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
> &FieldOffset));
> +EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
> &FieldOffset));
> +FType = CGM.getContext().getPointerType(Ty->getPointeeType());
> +EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
> &FieldOffset));
> +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> +FieldSize = CGM.getContext().getTypeSize(Ty);
> +FieldAlign = CGM.getContext().getTypeAlign(Ty);
> +EltTys.push_back(DBuilder.createMemberType(
> +Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
> FieldOffset,
> +llvm::DINode::FlagZero, DescTy));
> +  }
>

llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:7: error: variable
'FieldSize' is used uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
  if (CGM.getLangOpts().OpenCL) {
  ^~~~
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:994:18: note: uninitialized
use occurs here
  FieldOffset += FieldSize;
 ^
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:3: note: remove the 'if'
if its condition is always false
  if (CGM.getLangOpts().OpenCL) {
  ^~~
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:949:21: note: initialize the
variable 'FieldSize' to silence this warning
  uint64_t FieldSize, FieldOffset;
^
 = 0
1 error generated.


>FieldOffset += FieldSize;
>Elements = DBuilder.getOrCreateArray(EltTys);
> @@ -3847,26 +3852,35 @@ void CGDebugInfo::EmitDeclareOfBlockLite
>CGM.getDataLayout().getStructLayout(block.StructureType);
>
>SmallVector fields;
> -  fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public,
> -   blockLayout->getElementOffsetInBits(0),
> -   tunit, tunit));
> -  fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public,
> -   blockLayout->getElementOffsetInBits(1),
> -   tunit, tunit));
> -  fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public,
> -   blockLayout->getElementOffsetInBits(2),
> -   tunit, tunit));
> -  auto *FnTy = block.getBlockExpr()->getFunctionType();
> -  auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar());
> -  fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public,
> -

Re: r338455 - [constexpr] Support for constant evaluation of __builtin_memcpy and

2018-08-01 Thread Benjamin Kramer via cfe-commits
It's pretty easy to make this crash

$ cat memcpy.c
void foo() {
  int a[1], b;
  memcpy((char*)a, (const char*)&b, (unsigned long)4);
}

$ clang memcpy.c
llvm/include/llvm/ADT/SmallVector.h:178: const_reference
llvm::SmallVectorTemplateCommon::back() const [T = clang::APValue::LValue
PathEntry]: Assertion `!empty()' failed.

On Wed, Aug 1, 2018 at 1:35 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Jul 31 16:35:09 2018
> New Revision: 338455
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338455&view=rev
> Log:
> [constexpr] Support for constant evaluation of __builtin_memcpy and
> __builtin_memmove (in non-type-punning cases).
>
> This is intended to permit libc++ to make std::copy etc constexpr
> without sacrificing the optimization that uses memcpy on
> trivially-copyable types.
>
> __builtin_strcpy and __builtin_wcscpy are not handled by this change.
> They'd be straightforward to add, but we haven't encountered a need for
> them just yet.
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/CodeGen/builtin-memfns.c
> cfe/trunk/test/SemaCXX/constexpr-string.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=338455&r1=338454&r2=338455&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jul 31 16:35:09 2018
> @@ -471,6 +471,8 @@ BUILTIN(__builtin_wcslen, "zwC*", "nF")
>  BUILTIN(__builtin_wcsncmp, "iwC*wC*z", "nF")
>  BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF")
>  BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF")
> +BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF")
> +BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF")
>  BUILTIN(__builtin_return_address, "v*IUi", "n")
>  BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
>  BUILTIN(__builtin_frame_address, "v*IUi", "n")
> @@ -908,6 +910,8 @@ LIBBUILTIN(wcslen,  "zwC*", "f", "wc
>  LIBBUILTIN(wcsncmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
>  LIBBUILTIN(wmemchr, "w*wC*wz",  "f", "wchar.h", ALL_LANGUAGES)
>  LIBBUILTIN(wmemcmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
> +LIBBUILTIN(wmemcpy, "w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
> +LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
>
>  // C99
>  // In some systems setjmp is a macro that expands to _setjmp. We undefine
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=338455&r1=338454&r2=338455&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Tue Jul 31
> 16:35:09 2018
> @@ -163,6 +163,20 @@ def note_constexpr_unsupported_unsized_a
>  def note_constexpr_unsized_array_indexed : Note<
>"indexing of array without known bound is not allowed "
>"in a constant expression">;
> +def note_constexpr_memcpy_type_pun : Note<
> +  "cannot constant evaluate '%select{memcpy|memmove}0' from object of "
> +  "type %1 to object of type %2">;
> +def note_constexpr_memcpy_nontrivial : Note<
> +  "cannot constant evaluate '%select{memcpy|memmove}0' between objects of
> "
> +  "non-trivially-copyable type %1">;
> +def note_constexpr_memcpy_overlap : Note<
> +  "'%select{memcpy|wmemcpy}0' between overlapping memory regions">;
> +def note_constexpr_memcpy_unsupported : Note<
> +  "'%select{%select{memcpy|wmemcpy}1|%select{memmove|wmemmove}1}0' "
> +  "not supported: %select{"
> +  "size to copy (%4) is not a multiple of size of element type %3 (%5)|"
> +  "source is not a contiguous array of at least %4 elements of type %3|"
> +  "destination is not a contiguous array of at least %4 elements of type
> %3}2">;
>
>  def warn_integer_constant_overflow : Warning<
>"overflow in expression; result is %0 with type %1">,
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=338455&r1=338454&r2=338455&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Jul 31 16:35:09 2018
> @@ -319,6 +319,25 @@ namespace {
>return false;
>  }
>
> +/// Get the range of valid index adjustments in the form
> +///   {maximum value that can be subtracted from this pointer,
> +///maximum value that can be added to this pointer}
> +std::pair validIndexAdjustments() {
> +  if (Invalid || isMostDerivedAnUnsizedArray())
> +return {0, 0};
> +
> +  // [expr.add]p4

[clang-tools-extra] r324277 - [clangd] Add a cstring include for strerror.

2018-02-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb  5 14:10:39 2018
New Revision: 324277

URL: http://llvm.org/viewvc/llvm-project?rev=324277&view=rev
Log:
[clangd] Add a cstring include for strerror.

Apparently this doesn't get included transitively on some systems.

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

Modified: clang-tools-extra/trunk/clangd/Context.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Context.cpp?rev=324277&r1=324276&r2=324277&view=diff
==
--- clang-tools-extra/trunk/clangd/Context.cpp (original)
+++ clang-tools-extra/trunk/clangd/Context.cpp Mon Feb  5 14:10:39 2018
@@ -19,6 +19,7 @@
 // It requires support from the runtime: __cxa_thread_atexit.
 // Rather than detect this, we use the pthread API where available.
 #include 
+#include 
 static clang::clangd::Context ¤tContext() {
   using clang::clangd::Context;
   static pthread_key_t CtxKey;


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


[clang-tools-extra] r324389 - [clangd] Make the premble tremble.

2018-02-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Feb  6 12:08:23 2018
New Revision: 324389

URL: http://llvm.org/viewvc/llvm-project?rev=324389&view=rev
Log:
[clangd] Make the premble tremble.

No functionality change.

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=324389&r1=324388&r2=324389&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Feb  6 12:08:23 2018
@@ -547,7 +547,7 @@ CppFile::deferRebuild(ParseInputs &&Inpu
 log("Reusing preamble for file " + Twine(That->FileName));
 return OldPreamble;
   }
-  log("Premble for file " + Twine(That->FileName) +
+  log("Preamble for file " + Twine(That->FileName) +
   " cannot be reused. Attempting to rebuild it.");
   // We won't need the OldPreamble anymore, release it so it can be
   // deleted (if there are no other references to it).
@@ -628,7 +628,7 @@ CppFile::deferRebuild(ParseInputs &&Inpu
   if (That->ASTCallback)
 That->ASTCallback(That->FileName, NewAST.getPointer());
 } else {
-  // Don't report even Preamble diagnostics if we coulnd't build AST.
+  // Don't report even Preamble diagnostics if we couldn't build AST.
   Diagnostics.clear();
 }
 
@@ -739,7 +739,7 @@ SourceLocation clangd::getBeginningOfIde
   // after the end of a token. In theory we could just use GetBeginningOfToken
   // to find the start of the token at the input position, but this doesn't
   // work when right after the end, i.e. foo|.
-  // So try to go back by one and see if we're still inside the an identifier
+  // So try to go back by one and see if we're still inside an identifier
   // token. If so, Take the beginning of this token.
   // (It should be the same identifier because you can't have two adjacent
   // identifiers without another token in between.)


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


[clang-tools-extra] r325298 - [include-fixer] Add more debug headers to the STL header list

2018-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Feb 15 13:37:29 2018
New Revision: 325298

URL: http://llvm.org/viewvc/llvm-project?rev=325298&view=rev
Log:
[include-fixer] Add more debug headers to the STL header list

These are used for std::map/std::set in STL debug mode.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp?rev=325298&r1=325297&r2=325298&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
Thu Feb 15 13:37:29 2018
@@ -211,6 +211,10 @@ const HeaderMapCollector::RegexHeaderMap
   {"cwctype$", ""},
   {"cxxabi.h$", ""},
   {"debug/debug.h$", ""},
+  {"debug/map.h$", ""},
+  {"debug/multimap.h$", ""},
+  {"debug/multiset.h$", ""},
+  {"debug/set.h$", ""},
   {"deque$", ""},
   {"exception$", ""},
   {"ext/alloc_traits.h$", ""},


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


[clang-tools-extra] r325467 - [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts.

2018-02-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Feb 18 11:02:35 2018
New Revision: 325467

URL: http://llvm.org/viewvc/llvm-project?rev=325467&view=rev
Log:
[tidy] Move private ast matchers into anonymous namespaces to avoid ODR 
conflicts.

No functionality change intended.

Modified:
clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp

clang-tools-extra/trunk/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/TrailingReturnCheck.cpp
clang-tools-extra/trunk/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp
clang-tools-extra/trunk/clang-tidy/hicpp/NoAssemblerCheck.cpp

clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp?rev=325467&r1=325466&r2=325467&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp Sun Feb 18 
11:02:35 2018
@@ -15,10 +15,12 @@ namespace clang {
 namespace tidy {
 namespace boost {
 
+namespace {
 AST_MATCHER(Type, isStrictlyInteger) {
   return Node.isIntegerType() && !Node.isAnyCharacterType() &&
  !Node.isBooleanType();
 }
+} // namespace
 
 void UseToStringCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp?rev=325467&r1=325466&r2=325467&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp Sun 
Feb 18 11:02:35 2018
@@ -18,9 +18,11 @@ namespace clang {
 namespace tidy {
 namespace bugprone {
 
+namespace {
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
   return Node.getValue().getZExtValue() > N;
 }
+} // namespace
 
 StringConstructorCheck::StringConstructorCheck(StringRef Name,
ClangTidyContext *Context)

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp?rev=325467&r1=325466&r2=325467&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp Sun 
Feb 18 11:02:35 2018
@@ -19,11 +19,13 @@ namespace clang {
 namespace tidy {
 namespace bugprone {
 
+namespace {
 AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
 
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
   return Node.isOverloadedOperator();
 }
+} // namespace
 
 /// Finds out if the given method overrides some method.
 static bool isOverrideMethod(const CXXMethodDecl *MD) {

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp?rev=325467&r1=325466&r2=325467&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp Sun 
Feb 18 11:02:35 2018
@@ -17,9 +17,11 @@ namespace clang {
 namespace tidy {
 namespace cppcoreguidelines {
 
+namespace {
 AST_MATCHER(GotoStmt, isForwardJumping) {
   return Node.getLocStart() < Node.getLabel()->getLocStart();
 }
+} // namespace
 
 void AvoidGotoCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=325467&r1=325466&r2=325467&view=diff
==

r325468 - [Analyzer] Move UnexploredFirstStack into an anonymous namespace.

2018-02-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Feb 18 11:08:27 2018
New Revision: 325468

URL: http://llvm.org/viewvc/llvm-project?rev=325468&view=rev
Log:
[Analyzer] Move UnexploredFirstStack into an anonymous namespace.

No functionality change intended.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=325468&r1=325467&r2=325468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Sun Feb 18 11:08:27 2018
@@ -132,6 +132,7 @@ std::unique_ptr WorkList::make
   return llvm::make_unique();
 }
 
+namespace {
 class UnexploredFirstStack : public WorkList {
 
   /// Stack of nodes known to have statements we have not traversed yet.
@@ -185,6 +186,7 @@ public:
 }
   }
 };
+} // end anonymous namespace
 
 std::unique_ptr WorkList::makeUnexploredFirst() {
   return llvm::make_unique();


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


r304028 - Make helper functions static. NFC.

2017-05-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 26 15:08:24 2017
New Revision: 304028

URL: http://llvm.org/viewvc/llvm-project?rev=304028&view=rev
Log:
Make helper functions static. NFC.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=304028&r1=304027&r2=304028&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 26 15:08:24 2017
@@ -448,8 +448,8 @@ const Attr *Decl::getDefiningAttr() cons
   return nullptr;
 }
 
-StringRef getRealizedPlatform(const AvailabilityAttr *A,
-  const ASTContext &Context) {
+static StringRef getRealizedPlatform(const AvailabilityAttr *A,
+ const ASTContext &Context) {
   // Check if this is an App Extension "platform", and if so chop off
   // the suffix for matching with the actual platform.
   StringRef RealizedPlatform = A->getPlatform()->getName();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=304028&r1=304027&r2=304028&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri May 26 15:08:24 2017
@@ -1243,10 +1243,10 @@ static void emitReductionListCopy(
 ///local = local @ remote
 ///  else
 ///local = remote
-llvm::Value *emitReduceScratchpadFunction(CodeGenModule &CGM,
-  ArrayRef Privates,
-  QualType ReductionArrayTy,
-  llvm::Value *ReduceFn) {
+static llvm::Value *
+emitReduceScratchpadFunction(CodeGenModule &CGM,
+ ArrayRef Privates,
+ QualType ReductionArrayTy, llvm::Value *ReduceFn) 
{
   auto &C = CGM.getContext();
   auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);
 
@@ -1372,9 +1372,9 @@ llvm::Value *emitReduceScratchpadFunctio
 ///  for elem in Reduce List:
 ///scratchpad[elem_id][index] = elem
 ///
-llvm::Value *emitCopyToScratchpad(CodeGenModule &CGM,
-  ArrayRef Privates,
-  QualType ReductionArrayTy) {
+static llvm::Value *emitCopyToScratchpad(CodeGenModule &CGM,
+ ArrayRef Privates,
+ QualType ReductionArrayTy) {
 
   auto &C = CGM.getContext();
   auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=304028&r1=304027&r2=304028&view=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Fri May 26 15:08:24 2017
@@ -945,9 +945,9 @@ findLinesForRange(const CharSourceRange
 
 /// Add as much of range B into range A as possible without exceeding a maximum
 /// size of MaxRange. Ranges are inclusive.
-std::pair maybeAddRange(std::pair A,
-std::pair B,
-unsigned MaxRange) {
+static std::pair
+maybeAddRange(std::pair A, std::pair B,
+  unsigned MaxRange) {
   // If A is already the maximum size, we're done.
   unsigned Slack = MaxRange - (A.second - A.first + 1);
   if (Slack == 0)

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=304028&r1=304027&r2=304028&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May 26 15:08:24 2017
@@ -238,7 +238,7 @@ static typename std::enable_ifhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304030 - Remove unused diagnostics. NFC.

2017-05-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 26 15:14:12 2017
New Revision: 304030

URL: http://llvm.org/viewvc/llvm-project?rev=304030&view=rev
Log:
Remove unused diagnostics. NFC.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304030&r1=304029&r2=304030&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 26 15:14:12 
2017
@@ -1557,8 +1557,6 @@ def note_member_synthesized_at : Note<
   "in implicit %select{default constructor|copy constructor|move constructor|"
   "copy assignment operator|move assignment operator|destructor}0 for %1 "
   "first required here">;
-def note_inhctor_synthesized_at : Note<
-  "inherited constructor for %0 first required here">;
 def err_missing_default_ctor : Error<
   "%select{constructor for %1 must explicitly initialize the|"
   "implicit default constructor for %1 must explicitly initialize the|"
@@ -8909,8 +8907,6 @@ def note_equivalent_internal_linkage_dec
 
 def note_redefinition_modules_same_file : Note<
"'%0' included multiple times, additional include site in header from 
module '%1'">;
-def note_redefinition_modules_same_file_modulemap : Note<
-   "consider adding '%0' as part of '%1' definition">;
 def note_redefinition_include_same_file : Note<
"'%0' included multiple times, additional include site here">;
 }


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


r304167 - Unbreak long test after r304127.

2017-05-29 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon May 29 13:11:11 2017
New Revision: 304167

URL: http://llvm.org/viewvc/llvm-project?rev=304167&view=rev
Log:
Unbreak long test after r304127.

Modified:
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm_neon_intrinsics.c?rev=304167&r1=304166&r2=304167&view=diff
==
--- cfe/trunk/test/CodeGen/arm_neon_intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Mon May 29 13:11:11 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7s-apple-darwin -target-abi apcs-gnu\
-// RUN:  -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding 
-emit-llvm -o - %s \
+// RUN:  -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding \
+// RUN:  -disable-O0-optnone -emit-llvm -o - %s \
 // RUN:  | opt -S -mem2reg | FileCheck %s
 
 // REQUIRES: long-tests


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


r304205 - [PPC] Make altivec conversion function macros.

2017-05-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue May 30 06:37:29 2017
New Revision: 304205

URL: http://llvm.org/viewvc/llvm-project?rev=304205&view=rev
Log:
[PPC] Make altivec conversion function macros.

The second argument must be a constant, otherwise instruction selection
will fail. always_inline is not enough for isel to always fold
everything away at -O0.

Sadly the overloading turned this into a big macro mess. Fixes PR33212.

Added:
cfe/trunk/test/CodeGen/altivec-ct.c
Modified:
cfe/trunk/lib/Headers/altivec.h

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=304205&r1=304204&r2=304205&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Tue May 30 06:37:29 2017
@@ -2887,87 +2887,79 @@ static __inline__ vector double __ATTRS_
 
 /* vec_ctf */
 
-static __inline__ vector float __ATTRS_o_ai vec_ctf(vector int __a, int __b) {
-  return __builtin_altivec_vcfsx(__a, __b);
-}
-
-static __inline__ vector float __ATTRS_o_ai vec_ctf(vector unsigned int __a,
-int __b) {
-  return __builtin_altivec_vcfux((vector int)__a, __b);
-}
-
 #ifdef __VSX__
-static __inline__ vector double __ATTRS_o_ai
-vec_ctf(vector unsigned long long __a, int __b) {
-  vector double __ret = __builtin_convertvector(__a, vector double);
-  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
-  return __ret;
-}
-
-static __inline__ vector double __ATTRS_o_ai
-vec_ctf(vector signed long long __a, int __b) {
-  vector double __ret = __builtin_convertvector(__a, vector double);
-  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
-  return __ret;
-}
+#define vec_ctf(__a, __b)  
\
+  _Generic((__a), vector int   
\
+   : (vector float)__builtin_altivec_vcfsx((__a), (__b)),  
\
+ vector unsigned int   
\
+   : (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)),  
\
+ vector unsigned long long 
\
+   : (__builtin_convertvector((vector unsigned long long)(__a),
\
+  vector double) * 
\
+  (vector double)(vector unsigned long long)((0x3ffULL - (__b))
\
+ << 52)),  
\
+ vector signed long long   
\
+   : (__builtin_convertvector((vector signed long long)(__a),  
\
+  vector double) * 
\
+  (vector double)(vector unsigned long long)((0x3ffULL - (__b))
\
+ << 52)))
+#else
+#define vec_ctf(__a, __b)  
\
+  _Generic((__a), vector int   
\
+   : (vector float)__builtin_altivec_vcfsx((__a), (__b)),  
\
+ vector unsigned int   
\
+   : (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)))
 #endif
 
 /* vec_vcfsx */
 
-static __inline__ vector float __attribute__((__always_inline__))
-vec_vcfsx(vector int __a, int __b) {
-  return __builtin_altivec_vcfsx(__a, __b);
-}
+#define vec_vcfux __builtin_altivec_vcfux
 
 /* vec_vcfux */
 
-static __inline__ vector float __attribute__((__always_inline__))
-vec_vcfux(vector unsigned int __a, int __b) {
-  return __builtin_altivec_vcfux((vector int)__a, __b);
-}
+#define vec_vcfsx(__a, __b) __builtin_altivec_vcfsx((vector int)(__a), (__b))
 
 /* vec_cts */
 
-static __inline__ vector int __ATTRS_o_ai vec_cts(vector float __a, int __b) {
-  return __builtin_altivec_vctsxs(__a, __b);
-}
-
 #ifdef __VSX__
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_cts(vector double __a, int __b) {
-  __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
-  return __builtin_convertvector(__a, vector signed long long);
-}
+#define vec_cts(__a, __b)  
\
+  _Generic((__a), vector float 
\
+   : __builtin_altivec_vctsxs((__a), (__b)), vector double 
\
+   : __extension__({   
\
+ vector double __ret = 
\
+ (__a) *   
\
+ (vector double)(vector unsigned long long)((0x3ffULL + (__b)) 
\
+  

r304568 - [Modules] Fix use after scope.

2017-06-02 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  2 12:30:24 2017
New Revision: 304568

URL: http://llvm.org/viewvc/llvm-project?rev=304568&view=rev
Log:
[Modules] Fix use after scope.

Found by asan.

Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=304568&r1=304567&r2=304568&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Jun  2 12:30:24 2017
@@ -1989,6 +1989,7 @@ void ASTWriter::WriteHeaderSearch(const
   // have resolved them before we get here, but not necessarily: we might be
   // compiling a preprocessed module, where there is no requirement for the
   // original files to exist any more.
+  const HeaderFileInfo Empty; // So we can take a reference.
   if (WritingModule) {
 llvm::SmallVector Worklist(1, WritingModule);
 while (!Worklist.empty()) {
@@ -2027,7 +2028,7 @@ void ASTWriter::WriteHeaderSearch(const
   FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
 };
 HeaderFileInfoTrait::data_type Data = {
-  {}, {}, {M, ModuleMap::headerKindToRole(U.Kind)}
+  Empty, {}, {M, ModuleMap::headerKindToRole(U.Kind)}
 };
 // FIXME: Deal with cases where there are multiple unresolved header
 // directives in different submodules for the same header.


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


Re: r304515 - Support lazy stat'ing of files referenced by module maps.

2017-06-02 Thread Benjamin Kramer via cfe-commits
I committed a workaround in r304568.

On Fri, Jun 2, 2017 at 6:59 PM, Alexander Kornienko via cfe-commits
 wrote:
> I've not yet figured out exactly, but I have a suspicion that this commit
> causes crashes when run under asan. Specifically, when running
> test/Modules/preprocess-module.cpp
>
> The stack trace is:
> #0 0x1d644c6 in (anonymous
> namespace)::HeaderFileInfoTrait::EmitData(llvm::raw_ostream&, (anonymous
> namespace)::HeaderFileInfoTrait::key_type const&, (anonymous
> namespace)::HeaderFileInfoTrait::data_type const&, unsigned int)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:1926:39
> #1 0x1d322f3 in llvm::OnDiskChainedHashTableGenerator<(anonymous
> namespace)::HeaderFileInfoTrait>::Emit(llvm::raw_ostream&, (anonymous
> namespace)::HeaderFileInfoTrait&)
> llvm/include/llvm/Support/OnDiskHashTable.h:198:17
> #2 0x1d3168d in clang::ASTWriter::WriteHeaderSearch(clang::HeaderSearch
> const&) llvm/tools/clang/lib/Serialization/ASTWriter.cpp:2092:30
> #3 0x1d52f4c in clang::ASTWriter::WriteASTCore(clang::Sema&,
> llvm::StringRef, std::string const&, clang::Module*)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4857:3
> #4 0x1d4f7db in clang::ASTWriter::WriteAST(clang::Sema&, std::string
> const&, clang::Module*, llvm::StringRef, bool)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4475:7
> #5 0x1cd0333 in
> clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&)
> llvm/tools/clang/lib/Serialization/GeneratePCH.cpp:62:14
> #6 0x1f56cc7 in
> clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&)
> llvm/tools/clang/lib/Frontend/MultiplexConsumer.cpp:305:15
> #7 0x24ebc9c in clang::ParseAST(clang::Sema&, bool, bool)
> llvm/tools/clang/lib/Parse/ParseAST.cpp:159:13
> #8 0x1f4b283 in clang::FrontendAction::Execute()
> llvm/tools/clang/lib/Frontend/FrontendAction.cpp:856:8
> #9 0x1caf916 in
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:970:11
> #10 0x5ed12c in
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:25
>
> Could you take a look?
>
>
> On Fri, Jun 2, 2017 at 3:55 AM, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Jun  1 20:55:39 2017
>> New Revision: 304515
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304515&view=rev
>> Log:
>> Support lazy stat'ing of files referenced by module maps.
>>
>> This patch adds support for a `header` declaration in a module map to
>> specify
>> certain `stat` information (currently, size and mtime) about that header
>> file.
>> This has two purposes:
>>
>> - It removes the need to eagerly `stat` every file referenced by a module
>> map.
>>   Instead, we track a list of unresolved header files with each size /
>> mtime
>>   (actually, for simplicity, we track submodules with such headers), and
>> when
>>   attempting to look up a header file based on a `FileEntry`, we check if
>> there
>>   are any unresolved header directives with that `FileEntry`'s size /
>> mtime and
>>   perform deferred `stat`s if so.
>>
>> - It permits a preprocessed module to be compiled without the original
>> files
>>   being present on disk. The only reason we used to need those files was
>> to get
>>   the `stat` information in order to do header -> module lookups when
>> using the
>>   module. If we're provided with the `stat` information in the
>> preprocessed
>>   module, we can avoid requiring the files to exist.
>>
>> Unlike most `header` directives, if a `header` directive with `stat`
>> information has no corresponding on-disk file the enclosing module is
>> *not*
>> marked unavailable (so that behavior is consistent regardless of whether
>> we've
>> resolved a header directive, and so that preprocessed modules don't get
>> marked
>> unavailable). We could actually do this for all `header` directives: the
>> only
>> reason we mark the module unavailable if headers are missing is to give a
>> diagnostic slightly earlier (rather than waiting until we actually try to
>> build
>> the module / load and validate its .pcm file).
>>
>> Differential Revision: https://reviews.llvm.org/D33703
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/header-attribs/
>> cfe/trunk/test/Modules/Inputs/header-attribs/bar.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/baz.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/foo.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/modular.modulemap
>> cfe/trunk/test/Modules/Inputs/header-attribs/textual.modulemap
>> cfe/trunk/test/Modules/header-attribs.cpp
>> cfe/trunk/test/Modules/preprocess-missing.modulemap
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Lex/ModuleMap.h
>

r304892 - [Sema] Silence unused variable warning.

2017-06-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jun  7 05:23:17 2017
New Revision: 304892

URL: http://llvm.org/viewvc/llvm-project?rev=304892&view=rev
Log:
[Sema] Silence unused variable warning.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=304892&r1=304891&r2=304892&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun  7 05:23:17 2017
@@ -11843,7 +11843,7 @@ ExprResult Sema::BuildBinOp(Scope *S, So
   std::any_of(OE->decls_begin(), OE->decls_end(), [](NamedDecl *ND) {
 return isa(ND);
   })) {
-if (auto *Q = OE->getQualifier()) {
+if (OE->getQualifier()) {
   Diag(OE->getQualifierLoc().getBeginLoc(),
diag::err_template_kw_missing)
 << OE->getName().getAsString() << "";


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


r305094 - [ASTMatchers] Fix use after free.

2017-06-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  9 12:55:42 2017
New Revision: 305094

URL: http://llvm.org/viewvc/llvm-project?rev=305094&view=rev
Log:
[ASTMatchers] Fix use after free.

Found by asan.

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=305094&r1=305093&r2=305094&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Fri Jun  9 12:55:42 2017
@@ -206,7 +206,8 @@ private:
 if (isFloatingLiteral) {
   char *end;
   errno = 0;
-  double doubleValue = strtod(Result->Text.str().c_str(), &end);
+  std::string Text = Result->Text.str();
+  double doubleValue = strtod(Text.c_str(), &end);
   if (*end == 0 && errno == 0) {
 Result->Kind = TokenInfo::TK_Literal;
 Result->Value = doubleValue;


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


r305103 - Bringt back -triple so the test passes on non-x86.

2017-06-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  9 14:47:36 2017
New Revision: 305103

URL: http://llvm.org/viewvc/llvm-project?rev=305103&view=rev
Log:
Bringt back -triple so the test passes on non-x86.

Modified:
cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305103&r1=305102&r2=305103&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 14:47:36 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -verify 
-fsyntax-only %s
 
 #include 
 #include 


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


Re: r304207 - Allow for unfinished #if blocks in preambles

2017-06-23 Thread Benjamin Kramer via cfe-commits
Since this change went in I'm seeing spurious errors whenever editing
a header file, filed https://bugs.llvm.org/show_bug.cgi?id=33574 for
that.

On Tue, May 30, 2017 at 1:54 PM, Erik Verbruggen via cfe-commits
 wrote:
> Author: erikjv
> Date: Tue May 30 06:54:55 2017
> New Revision: 304207
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304207&view=rev
> Log:
> Allow for unfinished #if blocks in preambles
>
> Previously, a preamble only included #if blocks (and friends like
> ifdef) if there was a corresponding #endif before any declaration or
> definition. The problem is that any header file that uses include guards
> will not have a preamble generated, which can make code-completion very
> slow.
>
> To prevent errors about unbalanced preprocessor conditionals in the
> preamble, and unbalanced preprocessor conditionals after a preamble
> containing unfinished conditionals, the conditional stack is stored
> in the pch file.
>
> This fixes PR26045.
>
> Differential Revision: http://reviews.llvm.org/D15994
>
>
> Added:
> cfe/trunk/test/Lexer/preamble2.c
> Modified:
> cfe/trunk/include/clang/Lex/Preprocessor.h
> cfe/trunk/include/clang/Lex/PreprocessorLexer.h
> cfe/trunk/include/clang/Lex/PreprocessorOptions.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/Frontend/ASTUnit.cpp
> cfe/trunk/lib/Lex/Lexer.cpp
> cfe/trunk/lib/Lex/PPLexerChange.cpp
> cfe/trunk/lib/Lex/Preprocessor.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Lexer/preamble.c
>
> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=304207&r1=304206&r2=304207&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
> +++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue May 30 06:54:55 2017
> @@ -283,6 +283,44 @@ class Preprocessor {
>/// This is used when loading a precompiled preamble.
>std::pair SkipMainFilePreamble;
>
> +  class PreambleConditionalStackStore {
> +enum State {
> +  Off = 0,
> +  Recording = 1,
> +  Replaying = 2,
> +};
> +
> +  public:
> +PreambleConditionalStackStore() : ConditionalStackState(Off) {}
> +
> +void startRecording() { ConditionalStackState = Recording; }
> +void startReplaying() { ConditionalStackState = Replaying; }
> +bool isRecording() const { return ConditionalStackState == Recording; }
> +bool isReplaying() const { return ConditionalStackState == Replaying; }
> +
> +ArrayRef getStack() const {
> +  return ConditionalStack;
> +}
> +
> +void doneReplaying() {
> +  ConditionalStack.clear();
> +  ConditionalStackState = Off;
> +}
> +
> +void setStack(ArrayRef s) {
> +  if (!isRecording() && !isReplaying())
> +return;
> +  ConditionalStack.clear();
> +  ConditionalStack.append(s.begin(), s.end());
> +}
> +
> +bool hasRecordedPreamble() const { return !ConditionalStack.empty(); }
> +
> +  private:
> +SmallVector ConditionalStack;
> +State ConditionalStackState;
> +  } PreambleConditionalStack;
> +
>/// \brief The current top of the stack that we're lexing from if
>/// not expanding a macro and we are lexing directly from source code.
>///
> @@ -1695,6 +1733,11 @@ public:
>/// \brief Return true if we're in the top-level file, not in a \#include.
>bool isInPrimaryFile() const;
>
> +  /// \brief Return true if we're in the main file (specifically, if we are 0
> +  /// (zero) levels deep \#include. This is used by the lexer to determine if
> +  /// it needs to generate errors about unterminated \#if directives.
> +  bool isInMainFile() const;
> +
>/// \brief Handle cases where the \#include name is expanded
>/// from a macro as multiple tokens, which need to be glued together.
>///
> @@ -1932,6 +1975,27 @@ public:
>Module *M,
>SourceLocation 
> MLoc);
>
> +  bool isRecordingPreamble() const {
> +return PreambleConditionalStack.isRecording();
> +  }
> +
> +  bool hasRecordedPreamble() const {
> +return PreambleConditionalStack.hasRecordedPreamble();
> +  }
> +
> +  ArrayRef getPreambleConditionalStack() const {
> +  return PreambleConditionalStack.getStack();
> +  }
> +
> +  void setRecordedPreambleConditionalStack(ArrayRef s) {
> +PreambleConditionalStack.setStack(s);
> +  }
> +
> +  void setReplayablePreambleConditionalStack(ArrayRef s) {
> +PreambleConditionalStack.startReplaying();
> +PreambleConditionalStack.setStack(s);
> +  }
> +
>  private:
>// Macro handling.
>void HandleDefineDirective(Token &Tok, bool 
> ImmediatelyAfterTopLevelIfndef);
>
> Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h
> U

r320954 - Refactor overridden methods iteration to avoid double lookups.

2017-12-17 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 17 15:52:45 2017
New Revision: 320954

URL: http://llvm.org/viewvc/llvm-project?rev=320954&view=rev
Log:
Refactor overridden methods iteration to avoid double lookups.

Convert most uses to range-for loops. No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=320954&r1=320953&r2=320954&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Dec 17 15:52:45 2017
@@ -2015,7 +2015,7 @@ public:
 if (CD->isVirtualAsWritten() || CD->isPure())
   return true;
 
-return (CD->begin_overridden_methods() != CD->end_overridden_methods());
+return CD->size_overridden_methods() != 0;
   }
 
   /// If it's possible to devirtualize a call to this method, return the called

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=320954&r1=320953&r2=320954&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Dec 17 15:52:45 2017
@@ -1378,35 +1378,27 @@ void ASTContext::setInstantiatedFromUnna
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos =
-  OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-  return Pos->second.begin();
+  return overridden_methods(Method).begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos =
-  OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-  return Pos->second.end();
+  return overridden_methods(Method).end();
 }
 
 unsigned
 ASTContext::overridden_methods_size(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos =
-  OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return 0;
-  return Pos->second.size();
+  auto Range = overridden_methods(Method);
+  return Range.end() - Range.begin();
 }
 
 ASTContext::overridden_method_range
 ASTContext::overridden_methods(const CXXMethodDecl *Method) const {
-  return overridden_method_range(overridden_methods_begin(Method),
- overridden_methods_end(Method));
+  llvm::DenseMap::const_iterator Pos =
+  OverriddenMethods.find(Method->getCanonicalDecl());
+  if (Pos == OverriddenMethods.end())
+return overridden_method_range(nullptr, nullptr);
+  return overridden_method_range(Pos->second.begin(), Pos->second.end());
 }
 
 void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method, 

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=320954&r1=320953&r2=320954&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec 17 15:52:45 2017
@@ -1195,12 +1195,11 @@ void ASTDumper::VisitFunctionDecl(const
 };
 
   dumpChild([=] {
-auto FirstOverrideItr = MD->begin_overridden_methods();
+auto Overrides = MD->overridden_methods();
 OS << "Overrides: [ ";
-dumpOverride(*FirstOverrideItr);
+dumpOverride(*Overrides.begin());
 for (const auto *Override :
-   llvm::make_range(FirstOverrideItr + 1,
-MD->end_overridden_methods())) {
+ llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
   OS << ", ";
   dumpOverride(Override);
 }

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=320954&r1=320953&r2=320954&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Sun Dec 17 15:52:45 2017
@@ -650,9 +650,11 @@ void FinalOverriderCollect

[clang-tools-extra] r321286 - [clangd] Fix use after free.

2017-12-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 21 09:51:35 2017
New Revision: 321286

URL: http://llvm.org/viewvc/llvm-project?rev=321286&view=rev
Log:
[clangd] Fix use after free.

Found by asan.

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=321286&r1=321285&r2=321286&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Dec 21 
09:51:35 2017
@@ -95,9 +95,10 @@ bool SymbolCollector::handleDeclOccurenc
   return true;
 
 auto &SM = ND->getASTContext().getSourceManager();
-SymbolLocation Location = {
-makeAbsolutePath(SM, SM.getFilename(D->getLocation())),
-SM.getFileOffset(D->getLocStart()), SM.getFileOffset(D->getLocEnd())};
+std::string FilePath =
+makeAbsolutePath(SM, SM.getFilename(D->getLocation()));
+SymbolLocation Location = {FilePath, SM.getFileOffset(D->getLocStart()),
+   SM.getFileOffset(D->getLocEnd())};
 std::string QName = ND->getQualifiedNameAsString();
 auto ScopeAndName = splitQualifiedName(QName);
 Symbols.insert({std::move(ID), ScopeAndName.second, ScopeAndName.first,


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


r321425 - Make helpers static. No functionality change.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 04:46:22 2017
New Revision: 321425

URL: http://llvm.org/viewvc/llvm-project?rev=321425&view=rev
Log:
Make helpers static. No functionality change.

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=321425&r1=321424&r2=321425&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Dec 24 04:46:22 2017
@@ -2148,7 +2148,7 @@ static bool unionHasUniqueObjectRepresen
   return true;
 }
 
-bool isStructEmpty(QualType Ty) {
+static bool isStructEmpty(QualType Ty) {
   const RecordDecl *RD = Ty->castAs()->getDecl();
 
   if (!RD->field_empty())


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


r321429 - [AST] Inline CompoundStmt contents into the parent allocation.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 08:24:20 2017
New Revision: 321429

URL: http://llvm.org/viewvc/llvm-project?rev=321429&view=rev
Log:
[AST] Inline CompoundStmt contents into the parent allocation.

Saves a pointer on every CompoundStmt.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=321429&r1=321428&r2=321429&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Dec 24 08:24:20 2017
@@ -592,15 +592,21 @@ public:
 };
 
 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
-class CompoundStmt : public Stmt {
+class CompoundStmt final : public Stmt,
+   private llvm::TrailingObjects 
{
   friend class ASTStmtReader;
+  friend TrailingObjects;
 
-  Stmt** Body = nullptr;
   SourceLocation LBraceLoc, RBraceLoc;
 
+  CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB);
+  explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
+
+  void setStmts(ArrayRef Stmts);
+
 public:
-  CompoundStmt(const ASTContext &C, ArrayRef Stmts,
-   SourceLocation LB, SourceLocation RB);
+  static CompoundStmt *Create(const ASTContext &C, ArrayRef Stmts,
+  SourceLocation LB, SourceLocation RB);
 
   // \brief Build an empty compound statement with a location.
   explicit CompoundStmt(SourceLocation Loc)
@@ -609,11 +615,7 @@ public:
   }
 
   // \brief Build an empty compound statement.
-  explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {
-CompoundStmtBits.NumStmts = 0;
-  }
-
-  void setStmts(const ASTContext &C, ArrayRef Stmts);
+  static CompoundStmt *CreateEmpty(const ASTContext &C, unsigned NumStmts);
 
   bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
   unsigned size() const { return CompoundStmtBits.NumStmts; }
@@ -622,14 +624,16 @@ public:
   using body_range = llvm::iterator_range;
 
   body_range body() { return body_range(body_begin(), body_end()); }
-  body_iterator body_begin() { return Body; }
-  body_iterator body_end() { return Body + size(); }
-  Stmt *body_front() { return !body_empty() ? Body[0] : nullptr; }
-  Stmt *body_back() { return !body_empty() ? Body[size()-1] : nullptr; }
+  body_iterator body_begin() { return getTrailingObjects(); }
+  body_iterator body_end() { return body_begin() + size(); }
+  Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
+  Stmt *body_back() {
+return !body_empty() ? body_begin()[size() - 1] : nullptr;
+  }
 
   void setLastStmt(Stmt *S) {
 assert(!body_empty() && "setLastStmt");
-Body[size()-1] = S;
+body_begin()[size() - 1] = S;
   }
 
   using const_body_iterator = Stmt* const *;
@@ -639,15 +643,17 @@ public:
 return body_const_range(body_begin(), body_end());
   }
 
-  const_body_iterator body_begin() const { return Body; }
-  const_body_iterator body_end() const { return Body + size(); }
+  const_body_iterator body_begin() const {
+return getTrailingObjects();
+  }
+  const_body_iterator body_end() const { return body_begin() + size(); }
 
   const Stmt *body_front() const {
-return !body_empty() ? Body[0] : nullptr;
+return !body_empty() ? body_begin()[0] : nullptr;
   }
 
   const Stmt *body_back() const {
-return !body_empty() ? Body[size() - 1] : nullptr;
+return !body_empty() ? body_begin()[size() - 1] : nullptr;
   }
 
   using reverse_body_iterator = std::reverse_iterator;
@@ -682,13 +688,10 @@ public:
   }
 
   // Iterators
-  child_range children() {
-return child_range(Body, Body + CompoundStmtBits.NumStmts);
-  }
+  child_range children() { return child_range(body_begin(), body_end()); }
 
   const_child_range children() const {
-return const_child_range(child_iterator(Body),
- child_iterator(Body + CompoundStmtBits.NumStmts));
+return const_child_range(body_begin(), body_end());
   }
 };
 

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=321429&r1=321428&r2=321429&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sun Dec 24 08:24:20 2017
@@ -4321,9 +4321,8 @@ Stmt *ASTNodeImporter::VisitCompoundStmt
 
   SourceLocation ToLBraceLoc = Importer.Import(S->getLBracLoc());
   SourceLocation ToRBraceLoc = Importer.Import(S->getRBracLoc());
-  return new (Importer.getToContext()) Comp

r321428 - [AST] Convert AttributedStmt to llvm::TrailingObjects.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 08:24:11 2017
New Revision: 321428

URL: http://llvm.org/viewvc/llvm-project?rev=321428&view=rev
Log:
[AST] Convert AttributedStmt to llvm::TrailingObjects.

No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=321428&r1=321427&r2=321428&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Dec 24 08:24:11 2017
@@ -875,8 +875,11 @@ public:
 ///
 /// Represents an attribute applied to a statement. For example:
 ///   [[omp::for(...)]] for (...) { ... }
-class AttributedStmt : public Stmt {
+class AttributedStmt final
+: public Stmt,
+  private llvm::TrailingObjects {
   friend class ASTStmtReader;
+  friend TrailingObjects;
 
   Stmt *SubStmt;
   SourceLocation AttrLoc;
@@ -894,11 +897,9 @@ class AttributedStmt : public Stmt {
   }
 
   const Attr *const *getAttrArrayPtr() const {
-return reinterpret_cast(this + 1);
-  }
-  const Attr **getAttrArrayPtr() {
-return reinterpret_cast(this + 1);
+return getTrailingObjects();
   }
+  const Attr **getAttrArrayPtr() { return getTrailingObjects(); }
 
 public:
   static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=321428&r1=321427&r2=321428&view=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Sun Dec 24 08:24:11 2017
@@ -334,7 +334,7 @@ AttributedStmt *AttributedStmt::Create(c
ArrayRef Attrs,
Stmt *SubStmt) {
   assert(!Attrs.empty() && "Attrs should not be empty");
-  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * 
Attrs.size(),
+  void *Mem = C.Allocate(totalSizeToAlloc(Attrs.size()),
  alignof(AttributedStmt));
   return new (Mem) AttributedStmt(Loc, Attrs, SubStmt);
 }
@@ -342,7 +342,7 @@ AttributedStmt *AttributedStmt::Create(c
 AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C,
 unsigned NumAttrs) {
   assert(NumAttrs > 0 && "NumAttrs should be greater than zero");
-  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs,
+  void *Mem = C.Allocate(totalSizeToAlloc(NumAttrs),
  alignof(AttributedStmt));
   return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
 }


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


[clang-tools-extra] r321523 - [clangd] Simplify code. No functionality change intended.

2017-12-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 28 06:47:01 2017
New Revision: 321523

URL: http://llvm.org/viewvc/llvm-project?rev=321523&view=rev
Log:
[clangd] Simplify code. No functionality change intended.

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/FileIndex.h
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/MemIndex.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=321523&r1=321522&r2=321523&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Thu Dec 28 06:47:01 2017
@@ -37,7 +37,7 @@ void FileSymbols::update(PathRef Path, s
   if (!Slab)
 FileToSlabs.erase(Path);
   else
-FileToSlabs[Path] = std::shared_ptr(Slab.release());
+FileToSlabs[Path] = std::move(Slab);
 }
 
 std::shared_ptr> FileSymbols::allSymbols() {
@@ -74,9 +74,10 @@ void FileIndex::update(const Context &Ct
   Index.build(std::move(Symbols));
 }
 
-bool FileIndex::fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req,
-  std::function Callback) const {
-  return Index.fuzzyFind(Ctx, Req, std::move(Callback));
+bool FileIndex::fuzzyFind(
+const Context &Ctx, const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const {
+  return Index.fuzzyFind(Ctx, Req, Callback);
 }
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.h?rev=321523&r1=321522&r2=321523&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.h Thu Dec 28 06:47:01 2017
@@ -60,8 +60,9 @@ public:
   /// nullptr, this removes all symbols in the file
   void update(const Context &Ctx, PathRef Path, ParsedAST *AST);
 
-  bool fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req,
- std::function Callback) const override;
+  bool
+  fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const override;
 
 private:
   FileSymbols FSymbols;

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=321523&r1=321522&r2=321523&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Dec 28 06:47:01 2017
@@ -29,10 +29,6 @@ void operator>>(StringRef Str, SymbolID
   std::copy(HexString.begin(), HexString.end(), ID.HashValue.begin());
 }
 
-SymbolSlab::const_iterator SymbolSlab::begin() const { return Symbols.begin(); 
}
-
-SymbolSlab::const_iterator SymbolSlab::end() const { return Symbols.end(); }
-
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
   auto It = std::lower_bound(Symbols.begin(), Symbols.end(), ID,
  [](const Symbol &S, const SymbolID &I) {
@@ -50,9 +46,7 @@ static void own(Symbol &S, DenseSet(V.size());
-  memcpy(Data, V.data(), V.size());
-  *R.first = StringRef(Data, V.size());
+  *R.first = V.copy(Arena);
 }
 V = *R.first;
   };

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=321523&r1=321522&r2=321523&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Dec 28 06:47:01 2017
@@ -140,8 +140,8 @@ public:
 
   SymbolSlab() = default;
 
-  const_iterator begin() const;
-  const_iterator end() const;
+  const_iterator begin() const { return Symbols.begin(); }
+  const_iterator end() const { return Symbols.end(); }
   const_iterator find(const SymbolID &SymID) const;
 
   size_t size() const { return Symbols.size(); }
@@ -214,7 +214,7 @@ public:
   /// to MaxCandidateCount
   virtual bool
   fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req,
-std::function Callback) const = 0;
+llvm::function_ref Callback) const = 0;
 
   // FIXME: add interfaces for more index use cases:
   //  - Symbol getSymbolInfo(SymbolID);

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=321523&r1=321522&r2=321523&view=diff

[clang-tools-extra] r321525 - [clangd] Get rid of unnecessary global variable. No functionality change.

2017-12-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 28 07:03:02 2017
New Revision: 321525

URL: http://llvm.org/viewvc/llvm-project?rev=321525&view=rev
Log:
[clangd] Get rid of unnecessary global variable. No functionality change.

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=321525&r1=321524&r2=321525&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Dec 28 07:03:02 2017
@@ -266,7 +266,7 @@ bool fromJSON(const json::Expr &Params,
   return O && O.map("changes", R.changes);
 }
 
-const std::string ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
+const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
 "clangd.applyFix";
 
 bool fromJSON(const json::Expr &Params, ExecuteCommandParams &R) {

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=321525&r1=321524&r2=321525&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Dec 28 07:03:02 2017
@@ -380,7 +380,7 @@ json::Expr toJSON(const WorkspaceEdit &W
 /// one argument type will be parsed and set.
 struct ExecuteCommandParams {
   // Command to apply fix-its. Uses WorkspaceEdit as argument.
-  const static std::string CLANGD_APPLY_FIX_COMMAND;
+  const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;
 
   /// The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND
   std::string command;


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


r321526 - Avoid int to string conversion in Twine or raw_ostream contexts.

2017-12-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 28 08:58:54 2017
New Revision: 321526

URL: http://llvm.org/viewvc/llvm-project?rev=321526&view=rev
Log:
Avoid int to string conversion in Twine or raw_ostream contexts.

Some output changes from uppercase hex to lowercase hex, no other functionality 
change intended.

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Preprocessor/arm-acle-6.4.c
cfe/trunk/test/Preprocessor/arm-acle-6.5.c
cfe/trunk/test/Preprocessor/arm-target-features.c
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=321526&r1=321525&r2=321526&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Thu Dec 28 08:58:54 2017
@@ -159,7 +159,7 @@ void AArch64TargetInfo::getTargetDefines
 Builder.defineMacro("__ARM_FP_FAST", "1");
 
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
-  llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4));
+  Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
   Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : 
"4");
 

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=321526&r1=321525&r2=321526&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Thu Dec 28 08:58:54 2017
@@ -582,7 +582,7 @@ void ARMTargetInfo::getTargetDefines(con
 
   // ACLE 6.4.4 LDREX/STREX
   if (LDREX)
-Builder.defineMacro("__ARM_FEATURE_LDREX", "0x" + llvm::utohexstr(LDREX));
+Builder.defineMacro("__ARM_FEATURE_LDREX", "0x" + Twine::utohexstr(LDREX));
 
   // ACLE 6.4.5 CLZ
   if (ArchVersion == 5 || (ArchVersion == 6 && CPUProfile != "M") ||
@@ -591,7 +591,7 @@ void ARMTargetInfo::getTargetDefines(con
 
   // ACLE 6.5.1 Hardware Floating Point
   if (HW_FP)
-Builder.defineMacro("__ARM_FP", "0x" + llvm::utohexstr(HW_FP));
+Builder.defineMacro("__ARM_FP", "0x" + Twine::utohexstr(HW_FP));
 
   // ACLE predefines.
   Builder.defineMacro("__ARM_ACLE", "200");
@@ -672,11 +672,11 @@ void ARMTargetInfo::getTargetDefines(con
 // current AArch32 NEON implementations do not support double-precision
 // floating-point even when it is present in VFP.
 Builder.defineMacro("__ARM_NEON_FP",
-"0x" + llvm::utohexstr(HW_FP & ~HW_FP_DP));
+"0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
   }
 
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
-  llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4));
+  Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
   Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : 
"4");
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=321526&r1=321525&r2=321526&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Dec 28 08:58:54 2017
@@ -794,7 +794,7 @@ void SanitizerArgs::addArgs(const ToolCh
 
   if (MsanTrackOrigins)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins=" +
- llvm::utostr(MsanTrackOrigins)));
+ Twine(MsanTrackOrigins)));
 
   if (MsanUseAfterDtor)
 CmdArgs.push_back("-fsanitize-memory-use-after-dtor");
@@ -829,7 +829,7 @@ void SanitizerArgs::addArgs(const ToolCh
 
   if (AsanFieldPadding)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-field-padding=" +
- llvm::utostr(AsanFieldPadding)));
+ Twine(AsanFieldPadding)));
 
   if (AsanUseAfterScope)
 CmdArgs.push_back("-fsanitize-address-use-after-scope");

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=321526&r1=321525&r2=321526&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Dec 28 08:58:54 2017
@@ -1738,10 +1738,9 @@ void Clang::AddHexagonTargetArgs(const A
   CmdArgs.push_back("-Wreturn-type");
 
   if (auto G = toolchains::HexagonToolChai

[clang-tools-extra] r321526 - Avoid int to string conversion in Twine or raw_ostream contexts.

2017-12-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 28 08:58:54 2017
New Revision: 321526

URL: http://llvm.org/viewvc/llvm-project?rev=321526&view=rev
Log:
Avoid int to string conversion in Twine or raw_ostream contexts.

Some output changes from uppercase hex to lowercase hex, no other functionality 
change intended.

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

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=321526&r1=321525&r2=321526&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Thu Dec 28 08:58:54 
2017
@@ -196,7 +196,7 @@ void clangd::runLanguageServerLoop(std::
   log(Context::empty(),
   "Warning: Duplicate Content-Length header received. "
   "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  llvm::Twine(ContentLength) + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -230,10 +230,9 @@ void clangd::runLanguageServerLoop(std::
 // If the stream is aborted before we read ContentLength bytes, In
 // will have eofbit and failbit set.
 if (!In) {
-  log(Context::empty(), "Input was aborted. Read only " +
-std::to_string(In.gcount()) +
-" bytes of expected " +
-std::to_string(ContentLength) + ".\n");
+  log(Context::empty(),
+  "Input was aborted. Read only " + llvm::Twine(In.gcount()) +
+  " bytes of expected " + llvm::Twine(ContentLength) + ".\n");
   break;
 }
 


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


r321626 - [Sema] Fix build with GCC

2018-01-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Jan  1 09:07:23 2018
New Revision: 321626

URL: http://llvm.org/viewvc/llvm-project?rev=321626&view=rev
Log:
[Sema] Fix build with GCC

tools/clang/lib/Sema/DeclSpec.cpp: In member function 'void 
clang::DeclSpec::Finish(clang::Sema&, const clang::PrintingPolicy&)':
tools/clang/lib/Sema/DeclSpec.cpp:1116:8: error: could not convert 
'clang::DeclSpec::TSW_unspecified' from 'const TSW {aka const 
clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1117:8: error: could not convert 
'clang::DeclSpec::TSW_short' from 'const TSW {aka const 
clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1118:8: error: could not convert 
'clang::DeclSpec::TSW_longlong' from 'const TSW {aka const 
clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1128:8: error: could not convert 
'clang::DeclSpec::TSW_long' from 'const TSW {aka const 
clang::TypeSpecifierWidth}' to 'int'

Modified:
cfe/trunk/lib/Sema/DeclSpec.cpp

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=321626&r1=321625&r2=321626&view=diff
==
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Mon Jan  1 09:07:23 2018
@@ -1112,7 +1112,7 @@ void DeclSpec::Finish(Sema &S, const Pri
   }
 
   // Validate the width of the type.
-  switch (TypeSpecWidth) {
+  switch (static_cast(TypeSpecWidth)) {
   case TSW_unspecified: break;
   case TSW_short:// short int
   case TSW_longlong: // long long int


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


r321948 - Add support for a limited subset of TS 18661-3 math builtins.

2018-01-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Jan  6 13:49:54 2018
New Revision: 321948

URL: http://llvm.org/viewvc/llvm-project?rev=321948&view=rev
Log:
Add support for a limited subset of TS 18661-3 math builtins.

These just overloads for _Float128. They're supported by GCC 7 and used
by glibc. APFloat support is already there so just add the overloads.

__builtin_copysignf128
__builtin_fabsf128
__builtin_huge_valf128
__builtin_inff128
__builtin_nanf128
__builtin_nansf128

This is the same support that GCC has, according to the documentation,
but limited to _Float128.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/math-builtins.c
cfe/trunk/test/Sema/constant-builtins-2.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sat Jan  6 13:49:54 2018
@@ -48,8 +48,8 @@
 //  . -> "...".  This may only occur at the end of the function list.
 //
 // Types may be prefixed with the following modifiers:
-//  L   -> long (e.g. Li for 'long int')
-//  LL  -> long long
+//  L   -> long (e.g. Li for 'long int', Ld for 'long double')
+//  LL  -> long long (e.g. LLi for 'long long int', LLd for __float128)
 //  LLL -> __int128_t (e.g. LLLi)
 //  W   -> int64_t
 //  N   -> 'int' size if target is LP64, 'L' otherwise.
@@ -110,9 +110,11 @@ BUILTIN(__builtin_abs  , "ii"  , "ncF")
 BUILTIN(__builtin_copysign, "ddd", "ncF")
 BUILTIN(__builtin_copysignf, "fff", "ncF")
 BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
+BUILTIN(__builtin_copysignf128, "LLdLLdLLd", "ncF")
 BUILTIN(__builtin_fabs , "dd"  , "ncF")
 BUILTIN(__builtin_fabsf, "ff"  , "ncF")
 BUILTIN(__builtin_fabsl, "LdLd", "ncF")
+BUILTIN(__builtin_fabsf128, "LLdLLd", "ncF")
 BUILTIN(__builtin_fmod , "ddd"  , "Fne")
 BUILTIN(__builtin_fmodf, "fff"  , "Fne")
 BUILTIN(__builtin_fmodl, "LdLdLd", "Fne")
@@ -122,9 +124,11 @@ BUILTIN(__builtin_frexpl, "LdLdi*", "Fn"
 BUILTIN(__builtin_huge_val, "d", "nc")
 BUILTIN(__builtin_huge_valf, "f", "nc")
 BUILTIN(__builtin_huge_vall, "Ld", "nc")
+BUILTIN(__builtin_huge_valf128, "LLd", "nc")
 BUILTIN(__builtin_inf  , "d"   , "nc")
 BUILTIN(__builtin_inff , "f"   , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
+BUILTIN(__builtin_inff128 , "LLd"  , "nc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
 BUILTIN(__builtin_ldexp , "ddi"  , "Fne")
@@ -136,9 +140,11 @@ BUILTIN(__builtin_modfl, "LdLdLd*", "Fn"
 BUILTIN(__builtin_nan,  "dcC*" , "ncF")
 BUILTIN(__builtin_nanf, "fcC*" , "ncF")
 BUILTIN(__builtin_nanl, "LdcC*", "ncF")
+BUILTIN(__builtin_nanf128, "LLdcC*", "ncF")
 BUILTIN(__builtin_nans,  "dcC*" , "ncF")
 BUILTIN(__builtin_nansf, "fcC*" , "ncF")
 BUILTIN(__builtin_nansl, "LdcC*", "ncF")
+BUILTIN(__builtin_nansf128, "LLdcC*", "ncF")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")
 BUILTIN(__builtin_powil, "LdLdi", "Fnc")

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Jan  6 13:49:54 2018
@@ -8929,10 +8929,12 @@ static QualType DecodeTypeFromStr(const
 Type = Context.FloatTy;
 break;
   case 'd':
-assert(HowLong < 2 && !Signed && !Unsigned &&
+assert(HowLong < 3 && !Signed && !Unsigned &&
"Bad modifiers used with 'd'!");
-if (HowLong)
+if (HowLong == 1)
   Type = Context.LongDoubleTy;
+else if (HowLong == 2)
+  Type = Context.Float128Ty;
 else
   Type = Context.DoubleTy;
 break;

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Jan  6 13:49:54 2018
@@ -9170,9 +9170,11 @@ bool FloatExprEvaluator::VisitCallExpr(c
   case Builtin::BI__builtin_huge_val:
   case Builtin::BI__builtin_huge_valf:
   case Builtin::BI__builtin_huge_vall:
+  case Builtin::BI__builtin_huge_valf128:
   case Builtin::BI__builtin_inf:
   case Builtin::BI__builtin_inff:
-  case Builtin::BI__builtin_infl: {
+  case Builtin::BI__builtin_infl:
+  case Builtin::BI__builtin_inff128: {
 const llvm::fltSemantics &Sem =
   Info.Ctx.getFloatTypeSemantics(E->getType());
 Result = llvm::APFloat::getInf(Sem);
@@ -9182,6 +9184,7 @@ bool Floa

r321960 - Remove outdated doxygen comment [-Wdocumentation]

2018-01-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Jan  7 01:11:16 2018
New Revision: 321960

URL: http://llvm.org/viewvc/llvm-project?rev=321960&view=rev
Log:
Remove outdated doxygen comment [-Wdocumentation]

No functionality change.

Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=321960&r1=321959&r2=321960&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Sun Jan  7 01:11:16 2018
@@ -636,10 +636,6 @@ public:
   /// \param ExternModuleLoc The location of the "extern module" declaration
   ///that caused us to load this module map file, if any.
   ///
-  /// \param IsExplicitlyProvided Whether this module map file was provided
-  /// explicitly by the user (e.g. -fmodule-map-file), rather than found
-  /// implicitly.
-  ///
   /// \returns true if an error occurred, false otherwise.
   bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
   const DirectoryEntry *HomeDir,


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


Re: [PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-03-01 Thread Benjamin Kramer via cfe-commits
Frontend depends on StaticAnalyzerCore by
including "clang/StaticAnalyzer/Core/Analyses.def". That's a clear layering
violation, but cmake doesn't model header dependencies. Maybe Analyses.def
should move into its own library.


On Thu, Mar 1, 2018 at 3:07 PM Gábor Horváth via llvm-commits <
llvm-comm...@lists.llvm.org> wrote:

>
>
> 2018. márc. 1. 14:58 ezt írta ("Ilya Biryukov" ):
>
> I replied to a commit in the wrong thread (
> https://reviews.llvm.org/rL326323), sorry.
> Here are the important bits:
>
> This change introduced the following cyclic dependency in the build
> system: StaticAnalyzerCore -> CrossTU -> Frontend -> StaticAnalyzerCore.
>
>
> I do not see the Frontend -> StaticAnalyzerCore dependency upstream. See:
> https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/CMakeLists.txt
>
> Do I miss something here?
>
> Thanks in advance,
> Gábor
>
>
> I'm sorry, but I had to revert the commit in r326432. Cyclic dependency
> broke our internal integrate (we use a different buildsystem, which breaks
> on cyclic deps) and it's really messy to workaround it since CrossTU
> depends on both Index and Frontend.
> Moving the code that uses CrossTU from StaticAnalyzerCore to
> StaticAnalyzerFrontend should probably fix it, but I don't have enough
> context to come up with a fix.
>
>
>
> On Thu, Mar 1, 2018 at 2:01 PM Aleksei Sidorin via Phabricator via
> cfe-commits  wrote:
>
>> a.sidorin reopened this revision.
>> a.sidorin added a comment.
>>
>> The changes were reverted:
>> http://llvm.org/viewvc/llvm-project?rev=326432&view=rev
>> Gabor, could you take a look?
>>
>>
>> Repository:
>>   rC Clang
>>
>> https://reviews.llvm.org/D30691
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> --
> Regards,
> Ilya Biryukov
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334619 - [Basic] Fix -Wreorder warning

2018-06-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jun 13 09:45:12 2018
New Revision: 334619

URL: http://llvm.org/viewvc/llvm-project?rev=334619&view=rev
Log:
[Basic] Fix -Wreorder warning

Just use field initializers that don't suffer from this problem

Modified:
cfe/trunk/lib/Basic/Targets/PPC.h

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=334619&r1=334618&r2=334619&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Wed Jun 13 09:45:12 2018
@@ -49,33 +49,30 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetI
   } ArchDefineTypes;
 
 
-  ArchDefineTypes ArchDefs;
+  ArchDefineTypes ArchDefs = ArchDefineNone;
   static const Builtin::Info BuiltinInfo[];
   static const char *const GCCRegNames[];
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
   std::string CPU;
 
   // Target cpu features.
-  bool HasAltivec;
-  bool HasVSX;
-  bool HasP8Vector;
-  bool HasP8Crypto;
-  bool HasDirectMove;
-  bool HasQPX;
-  bool HasHTM;
-  bool HasBPERMD;
-  bool HasExtDiv;
-  bool HasP9Vector;
+  bool HasAltivec = false;
+  bool HasVSX = false;
+  bool HasP8Vector = false;
+  bool HasP8Crypto = false;
+  bool HasDirectMove = false;
+  bool HasQPX = false;
+  bool HasHTM = false;
+  bool HasBPERMD = false;
+  bool HasExtDiv = false;
+  bool HasP9Vector = false;
 
 protected:
   std::string ABI;
 
 public:
   PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), HasAltivec(false), HasVSX(false),
-HasP8Vector(false), HasP8Crypto(false), HasDirectMove(false),
-HasQPX(false), HasHTM(false), HasBPERMD(false), HasExtDiv(false),
-HasP9Vector(false), ArchDefs(ArchDefineNone) {
+  : TargetInfo(Triple) {
 SuitableAlign = 128;
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;


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


r335330 - [hmaptool] Turn %hmaptool into a proper substitution

2018-06-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun 22 02:46:40 2018
New Revision: 335330

URL: http://llvm.org/viewvc/llvm-project?rev=335330&view=rev
Log:
[hmaptool] Turn %hmaptool into a proper substitution

This is still super ugly, but at least it doesn't require working
directories to just line up perfectly for python to find the tool.

Modified:
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Preprocessor/headermap-rel.c
cfe/trunk/test/Preprocessor/headermap-rel2.c
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335330&r1=335329&r2=335330&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Fri Jun 22 02:46:40 2018
@@ -3,7 +3,7 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
 // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
-// RUN: '%python' hmaptool write 
%S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap
+// RUN: %hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json 
%t/i/foo.hmap
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \

Modified: cfe/trunk/test/Preprocessor/headermap-rel.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel.c?rev=335330&r1=335329&r2=335330&view=diff
==
--- cfe/trunk/test/Preprocessor/headermap-rel.c (original)
+++ cfe/trunk/test/Preprocessor/headermap-rel.c Fri Jun 22 02:46:40 2018
@@ -1,5 +1,5 @@
 // RUN: rm -f %t.hmap
-// RUN: '%python' hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap
+// RUN: %hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap
 // RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel
 // RUN: FileCheck %s -input-file %t.i
 

Modified: cfe/trunk/test/Preprocessor/headermap-rel2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel2.c?rev=335330&r1=335329&r2=335330&view=diff
==
--- cfe/trunk/test/Preprocessor/headermap-rel2.c (original)
+++ cfe/trunk/test/Preprocessor/headermap-rel2.c Fri Jun 22 02:46:40 2018
@@ -1,5 +1,5 @@
 // RUN: rm -f %t.hmap
-// RUN: '%python' hmaptool write 
%S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap
+// RUN: %hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json 
%t.hmap
 // RUN: %clang_cc1 -v -fsyntax-only %s -iquote %t.hmap -isystem 
%S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H
 // RUN: %clang_cc1 -fsyntax-only %s -iquote %t.hmap -isystem 
%S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> 
%t.out
 // RUN: FileCheck %s -input-file %t.out

Modified: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c?rev=335330&r1=335329&r2=335330&view=diff
==
--- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c (original)
+++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Fri Jun 22 
02:46:40 2018
@@ -1,5 +1,5 @@
 // RUN: rm -f %t.hmap
-// RUN: '%python' hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json 
%t.hmap
+// RUN: %hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap
 // RUN: %clang_cc1 -Eonly\
 // RUN:   -I%t.hmap \
 // RUN:   -I%S/Inputs/nonportable-hmaps  \

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335330&r1=335329&r2=335330&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Fri Jun 22 02:46:40 2018
@@ -58,7 +58,7 @@ tool_dirs = [config.clang_tools_dir, con
 
 tools = [
 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 
'clang-tblgen',
-'opt', 'hmaptool',
+'opt',
 ToolSubst('%clang_func_map', command=FindTool(
 'clang-func-mapping'), unresolved='ignore'),
 ]
@@ -69,6 +69,10 @@ if config.clang_examples:
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
+config.substitutions.append(
+('%hmaptool', '%s %s' % (config.python_executable,
+ os.path.join(config.llvm_tools_dir, 'hmaptool'
+
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
 if sys.platform in ['win32', 'cygwin']:


___
cfe-commits mailing list
cfe-commits@lis

r335382 - Reinstate quotes around the path to python that I accidentaly removed in r335330

2018-06-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun 22 13:03:32 2018
New Revision: 335382

URL: http://llvm.org/viewvc/llvm-project?rev=335382&view=rev
Log:
Reinstate quotes around the path to python that I accidentaly removed in r335330

This broke users with spaces in the path, like C:\Program Files\Python

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335382&r1=335381&r2=335382&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Fri Jun 22 13:03:32 2018
@@ -70,7 +70,7 @@ if config.clang_examples:
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
 config.substitutions.append(
-('%hmaptool', '%s %s' % (config.python_executable,
+('%hmaptool', "'%s' %s" % (config.python_executable,
  os.path.join(config.llvm_tools_dir, 'hmaptool'
 
 # Plugins (loadable modules)


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


[clang-tools-extra] r344468 - Move some helpers from the global namespace into anonymous ones.

2018-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 13 15:18:22 2018
New Revision: 344468

URL: http://llvm.org/viewvc/llvm-project?rev=344468&view=rev
Log:
Move some helpers from the global namespace into anonymous ones.

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

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Sat Oct 13 15:18:22 2018
@@ -72,7 +72,8 @@ public:
 } // namespace
 
 // Returns callbacks that can be used to update the FileIndex with new ASTs.
-std::unique_ptr makeUpdateCallbacks(FileIndex *FIndex) {
+static std::unique_ptr
+makeUpdateCallbacks(FileIndex *FIndex) {
   struct CB : public ParsingCallbacks {
 CB(FileIndex *FIndex) : FIndex(FIndex) {}
 FileIndex *FIndex;


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


r344468 - Move some helpers from the global namespace into anonymous ones.

2018-10-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 13 15:18:22 2018
New Revision: 344468

URL: http://llvm.org/viewvc/llvm-project?rev=344468&view=rev
Log:
Move some helpers from the global namespace into anonymous ones.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Sat Oct 13 
15:18:22 2018
@@ -196,6 +196,7 @@ bool CallAndMessageChecker::uninitRefOrP
   return false;
 }
 
+namespace {
 class FindUninitializedField {
 public:
   SmallVector FieldChain;
@@ -234,6 +235,7 @@ public:
 return false;
   }
 };
+} // namespace
 
 bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
SVal V,

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Sat Oct 13 
15:18:22 2018
@@ -337,6 +337,7 @@ void ExprInspectionChecker::analyzerDeno
   C.addTransition(C.getState()->set(Sym, E));
 }
 
+namespace {
 class SymbolExpressor
 : public SymExprVisitor> {
   ProgramStateRef State;
@@ -369,6 +370,7 @@ public:
 return None;
   }
 };
+} // namespace
 
 void ExprInspectionChecker::analyzerExpress(const CallExpr *CE,
 CheckerContext &C) const {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=344468&r1=344467&r2=344468&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sat Oct 13 15:18:22 2018
@@ -98,11 +98,12 @@ STATISTIC(NumMaxBlockCountReachedInInlin
 STATISTIC(NumTimesRetriedWithoutInlining,
 "The # of times we re-evaluated a call without inlining");
 
-
 
//===--===//
 // Internal program state traits.
 
//===--===//
 
+namespace {
+
 // When modeling a C++ constructor, for a variety of reasons we need to track
 // the location of the object for the duration of its ConstructionContext.
 // ObjectsUnderConstruction maps statements within the construction context
@@ -164,6 +165,7 @@ public:
 return Impl < RHS.Impl;
   }
 };
+} // namespace
 
 typedef llvm::ImmutableMap
 ObjectsUnderConstructionMap;


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


[clang-tools-extra] r344968 - [clang-tidy] Fix typo abls->absl.

2018-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct 22 15:43:17 2018
New Revision: 344968

URL: http://llvm.org/viewvc/llvm-project?rev=344968&view=rev
Log:
[clang-tidy] Fix typo abls->absl.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-str-cat-append.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-str-cat-append.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-str-cat-append.rst?rev=344968&r1=344967&r2=344968&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-str-cat-append.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-str-cat-append.rst 
Mon Oct 22 15:43:17 2018
@@ -13,5 +13,5 @@ them makes the code smaller and faster.
 
   a = absl::StrCat(a, b); // Use absl::StrAppend(&a, b) instead.
 
-Does not diagnose cases where ``abls::StrCat()`` is used as a template 
+Does not diagnose cases where ``absl::StrCat()`` is used as a template
 argument for a functor.


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


r351007 - [analyzer] Fix unused variable warnings in Release builds

2019-01-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Jan 12 04:43:53 2019
New Revision: 351007

URL: http://llvm.org/viewvc/llvm-project?rev=351007&view=rev
Log:
[analyzer] Fix unused variable warnings in Release builds

This was just an inlined version of isa. NFC.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=351007&r1=351006&r2=351007&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Sat Jan 12 04:43:53 2019
@@ -1372,12 +1372,9 @@ CallEventManager::getCaller(const StackF
 if (CallEventRef<> Out = getCall(CallSite, State, CallerCtx))
   return Out;
 
-Stmt::StmtClass SC = CallSite->getStmtClass();
-
 // All other cases are handled by getCall.
-assert(SC == Stmt::CXXConstructExprClass ||
-   SC == Stmt::CXXTemporaryObjectExprClass &&
-   "This is not an inlineable statement");
+assert(isa(CallSite) &&
+   "This is not an inlineable statement");
 
 SValBuilder &SVB = State->getStateManager().getSValBuilder();
 const auto *Ctor = cast(CalleeCtx->getDecl());


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


Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-15 Thread Benjamin Kramer via cfe-commits
I'm seeing breakages on v8 with this, it defines its own _xgetbv. Any ideas
what do do about this?

https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36

src/x64/assembler-x64.cc:35:1: error: inline variables are incompatible
with C++ standards before C++17 [-Werror,-Wc++98-c++11-c++14-compat]
V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
^
include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
   ^
src/x64/assembler-x64.cc:35:41: error: expected ')'
V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
^
src/x64/assembler-x64.cc:35:20: note: to match this '('
V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
   ^
lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro '_xgetbv'
#define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))

On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ctopper
> Date: Mon Jan 14 21:03:18 2019
> New Revision: 351160
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
> Log:
> [X86] Make _xgetbv/_xsetbv on non-windows platforms
>
> Summary:
> This patch attempts to redo what was tried in r278783, but was reverted.
>
> These intrinsics should be available on non-windows platforms with "xsave"
> feature check. But on Windows platforms they shouldn't have feature check
> since that's how MSVC behaves.
>
> To accomplish this I've added a MS builtin with no feature check. And a
> normal gcc builtin with a feature check. When _MSC_VER is not defined
> _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
>
> I've moved the forward declarations from intrin.h to immintrin.h to match
> the MSDN documentation and used that as the header file for the MS builtin.
>
> I'm not super happy with this implementation, and I'm open to suggestions
> for better ways to do it.
>
> Reviewers: rnk, RKSimon, spatel
>
> Reviewed By: rnk
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D56686
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/immintrin.h
> cfe/trunk/lib/Headers/intrin.h
> cfe/trunk/lib/Headers/xsaveintrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
> cfe/trunk/test/CodeGen/x86_32-xsave.c
> cfe/trunk/test/CodeGen/x86_64-xsave.c
> cfe/trunk/test/Headers/ms-intrin.cpp
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351160&r1=351159&r2=351160&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jan 14 21:03:18 2019
> @@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
>  // XSAVE
>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
> +TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h",
> ALL_MS_LANGUAGES, "")
>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
>  TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
>  TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351160&r1=351159&r2=351160&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jan 14 21:03:18 2019
> @@ -9831,7 +9831,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>case X86::BI__builtin_ia32_xsavec:
>case X86::BI__builtin_ia32_xsavec64:
>case X86::BI__builtin_ia32_xsaves:
> -  case X86::BI__builtin_ia32_xsaves64: {
> +  case X86::BI__builtin_ia32_xsaves64:
> +  case X86::BI__builtin_ia32_xsetbv:
> +  case X86::BI_xsetbv: {
>  Intrinsic::ID ID;
>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>  case X86::BI__builtin_ia32_##NAME: \
> @@ -9851,6 +9853,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>  INTRINSIC_X86_XSAVE_ID(xsaves);
>  INTRINSIC_X86_XSAVE_ID(xsaves64);
> +INTRINSIC_X86_XSAVE_ID(xsetbv);
> +case X86::BI_xsetbv:
> +  ID = Intrinsic::x86_xsetbv;
> +  break;
>  }
>  #undef INTRINSIC_X86_XSAVE_ID
>  Value *Mhi = Builder.CreateTrunc(
> @@ -9860,6 +9866,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  Ops.push_back(Mlo);
>  return Builder.CreateCall(CGM.getIn

[clang-tools-extra] r351208 - Revert "Update clang-tools-extra for r350891 from Clang."

2019-01-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Jan 15 09:20:04 2019
New Revision: 351208

URL: http://llvm.org/viewvc/llvm-project?rev=351208&view=rev
Log:
Revert "Update clang-tools-extra for r350891 from Clang."

This reverts commit r350892.

Modified:
clang-tools-extra/trunk/test/modularize/ProblemsInconsistent.modularize
clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp
clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp

Modified: 
clang-tools-extra/trunk/test/modularize/ProblemsInconsistent.modularize
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/ProblemsInconsistent.modularize?rev=351208&r1=351207&r2=351208&view=diff
==
--- clang-tools-extra/trunk/test/modularize/ProblemsInconsistent.modularize 
(original)
+++ clang-tools-extra/trunk/test/modularize/ProblemsInconsistent.modularize Tue 
Jan 15 09:20:04 2019
@@ -60,6 +60,16 @@ Inputs/InconsistentHeader2.h
 # CHECK-NEXT: {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentHeader2.h
 # CHECK-NEXT:   {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentSubHeader.h
 # CHECK-NEXT: (no macro definition)
+# CHECK-NEXT: {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentSubHeader.h:11:2
+# CHECK-NEXT: #if SYMBOL == 1
+# CHECK-NEXT: ^
+# CHECK-NEXT: error: Conditional expression instance 'SYMBOL == 1' has 
different values in this header, depending on how it was included.
+# CHECK-NEXT:   'SYMBOL == 1' expanded to: 'true' with respect to these 
inclusion paths:
+# CHECK-NEXT: {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentHeader1.h
+# CHECK-NEXT:   {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentSubHeader.h
+# CHECK-NEXT:   'SYMBOL == 1' expanded to: 'false' with respect to these 
inclusion paths:
+# CHECK-NEXT: {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentHeader2.h
+# CHECK-NEXT:   {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentSubHeader.h
 # CHECK-NEXT: {{.*}}{{[/\\]}}Inputs{{[/\\]}}InconsistentSubHeader.h:2:2
 # CHECK-NEXT: #ifdef SYMBOL1
 # CHECK-NEXT: ^

Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp?rev=351208&r1=351207&r2=351208&view=diff
==
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp Tue Jan 15 
09:20:04 2019
@@ -79,14 +79,14 @@
 // CHECK-NEXT:   MacroDirective: MD_Define
 // CHECK:  - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:3:2"
-// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:3:5", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:3:5"]
+// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:3:4", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:4:1"]
 // CHECK-NEXT:   ConditionValue: CVK_True
 // CHECK-NEXT: - Callback: Endif
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:4:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:3:2"
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:2"
-// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:5", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:5"]
+// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:4", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:1"]
 // CHECK-NEXT:   ConditionValue: CVK_False
 // CHECK-NEXT: - Callback: Endif
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:2"
@@ -95,7 +95,7 @@
 // CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:1", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:2"
-// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:5", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:5"]
+// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:4", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:1"]
 // CHECK-NEXT:   ConditionValue: CVK_True
 // CHECK-NEXT: - Callback: Else
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:2"
@@ -107,7 +107,7 @@
 // CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:1", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:11:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:2"
-// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:5", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:5"]
+// CHECK-NEXT:   ConditionRange: 
["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:4", 
"{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:1"]
 // CHECK-NEXT:   ConditionValue: CVK_False
 // CHECK-NEXT: - Callback: Else
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:2"
@@ -119,11 +119,11 @@
 // CHECK-NEXT:   If

r351209 - Revert "Correct the source range returned from preprocessor callbacks."

2019-01-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Jan 15 09:20:05 2019
New Revision: 351209

URL: http://llvm.org/viewvc/llvm-project?rev=351209&view=rev
Log:
Revert "Correct the source range returned from preprocessor callbacks."

This reverts commit r350891. Also add a test case that would return an
empty string with r350891.

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPExpressions.cpp
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=351209&r1=351208&r2=351209&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Jan 15 09:20:05 2019
@@ -1816,8 +1816,8 @@ public:
   void CheckEndOfDirective(const char *DirType, bool EnableMacros = false);
 
   /// Read and discard all tokens remaining on the current line until
-  /// the tok::eod token is found. Returns the range of the skipped tokens.
-  SourceRange DiscardUntilEndOfDirective();
+  /// the tok::eod token is found.
+  void DiscardUntilEndOfDirective();
 
   /// Returns true if the preprocessor has seen a use of
   /// __DATE__ or __TIME__ in the file so far.
@@ -1982,9 +1982,6 @@ private:
 
 /// True if the expression contained identifiers that were undefined.
 bool IncludedUndefinedIds;
-
-/// The source range for the expression.
-SourceRange ExprRange;
   };
 
   /// Evaluate an integer constant expression that may occur after a

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=351209&r1=351208&r2=351209&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Jan 15 09:20:05 2019
@@ -79,18 +79,12 @@ Preprocessor::AllocateVisibilityMacroDir
 
 /// Read and discard all tokens remaining on the current line until
 /// the tok::eod token is found.
-SourceRange Preprocessor::DiscardUntilEndOfDirective() {
+void Preprocessor::DiscardUntilEndOfDirective() {
   Token Tmp;
-  SourceRange Res;
-
-  LexUnexpandedToken(Tmp);
-  Res.setBegin(Tmp.getLocation());
-  while (Tmp.isNot(tok::eod)) {
-assert(Tmp.isNot(tok::eof) && "EOF seen while discarding directive 
tokens");
+  do {
 LexUnexpandedToken(Tmp);
-  }
-  Res.setEnd(Tmp.getLocation());
-  return Res;
+assert(Tmp.isNot(tok::eof) && "EOF seen while discarding directive 
tokens");
+  } while (Tmp.isNot(tok::eod));
 }
 
 /// Enumerates possible cases of #define/#undef a reserved identifier.
@@ -544,19 +538,19 @@ void Preprocessor::SkipExcludedCondition
 if (CondInfo.WasSkipping || CondInfo.FoundNonSkip) {
   DiscardUntilEndOfDirective();
 } else {
+  const SourceLocation CondBegin = CurPPLexer->getSourceLocation();
   // Restore the value of LexingRawMode so that identifiers are
   // looked up, etc, inside the #elif expression.
   assert(CurPPLexer->LexingRawMode && "We have to be skipping here!");
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
-  DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
-  const bool CondValue = DER.Conditional;
+  const bool CondValue = 
EvaluateDirectiveExpression(IfNDefMacro).Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
-Callbacks->Elif(
-Tok.getLocation(), DER.ExprRange,
-(CondValue ? PPCallbacks::CVK_True : PPCallbacks::CVK_False),
-CondInfo.IfLoc);
+const SourceLocation CondEnd = CurPPLexer->getSourceLocation();
+Callbacks->Elif(Tok.getLocation(),
+SourceRange(CondBegin, CondEnd),
+(CondValue ? PPCallbacks::CVK_True : 
PPCallbacks::CVK_False), CondInfo.IfLoc);
   }
   // If this condition is true, enter it!
   if (CondValue) {
@@ -1122,24 +1116,19 @@ void Preprocessor::HandleLineDirective()
 ; // ok
   else if (StrTok.isNot(tok::string_literal)) {
 Diag(StrTok, diag::err_pp_line_invalid_filename);
-DiscardUntilEndOfDirective();
-return;
+return DiscardUntilEndOfDirective();
   } else if (StrTok.hasUDSuffix()) {
 Diag(StrTok, diag::err_invalid_string_udl);
-DiscardUntilEndOfDirective();
-return;
+return DiscardUntilEndOfDirective();
   } else {
 // Parse and validate the string, converting it into a unique ID.
 StringLiteralParser Literal(StrTok, *this);
 assert(Literal.isAscii() && "Didn't allow wide strings in");
-if (Literal.hadError) {
-  DiscardUntilEndOfDirective();
-  return;
-}
+if (Literal.hadError)
+ 

Re: r350891 - Correct the source range returned from preprocessor callbacks.

2019-01-15 Thread Benjamin Kramer via cfe-commits
With this patch some ranges just come back empty. I rolled the change back
in r351209, which also includes a test case that shows the empty ranges
with this patch.

On Thu, Jan 10, 2019 at 10:26 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Thu Jan 10 13:22:13 2019
> New Revision: 350891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350891&view=rev
> Log:
> Correct the source range returned from preprocessor callbacks.
>
> This adjusts the source range passed in to the preprocessor callbacks to
> only include the condition range itself, rather than all of the
> conditionally skipped tokens.
>
> Modified:
> cfe/trunk/include/clang/Lex/Preprocessor.h
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/lib/Lex/PPExpressions.cpp
> cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
>
> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=350891&r1=350890&r2=350891&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
> +++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan 10 13:22:13 2019
> @@ -1816,8 +1816,8 @@ public:
>void CheckEndOfDirective(const char *DirType, bool EnableMacros =
> false);
>
>/// Read and discard all tokens remaining on the current line until
> -  /// the tok::eod token is found.
> -  void DiscardUntilEndOfDirective();
> +  /// the tok::eod token is found. Returns the range of the skipped
> tokens.
> +  SourceRange DiscardUntilEndOfDirective();
>
>/// Returns true if the preprocessor has seen a use of
>/// __DATE__ or __TIME__ in the file so far.
> @@ -1982,6 +1982,9 @@ private:
>
>  /// True if the expression contained identifiers that were undefined.
>  bool IncludedUndefinedIds;
> +
> +/// The source range for the expression.
> +SourceRange ExprRange;
>};
>
>/// Evaluate an integer constant expression that may occur after a
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=350891&r1=350890&r2=350891&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Jan 10 13:22:13 2019
> @@ -79,12 +79,18 @@ Preprocessor::AllocateVisibilityMacroDir
>
>  /// Read and discard all tokens remaining on the current line until
>  /// the tok::eod token is found.
> -void Preprocessor::DiscardUntilEndOfDirective() {
> +SourceRange Preprocessor::DiscardUntilEndOfDirective() {
>Token Tmp;
> -  do {
> -LexUnexpandedToken(Tmp);
> +  SourceRange Res;
> +
> +  LexUnexpandedToken(Tmp);
> +  Res.setBegin(Tmp.getLocation());
> +  while (Tmp.isNot(tok::eod)) {
>  assert(Tmp.isNot(tok::eof) && "EOF seen while discarding directive
> tokens");
> -  } while (Tmp.isNot(tok::eod));
> +LexUnexpandedToken(Tmp);
> +  }
> +  Res.setEnd(Tmp.getLocation());
> +  return Res;
>  }
>
>  /// Enumerates possible cases of #define/#undef a reserved identifier.
> @@ -538,19 +544,19 @@ void Preprocessor::SkipExcludedCondition
>  if (CondInfo.WasSkipping || CondInfo.FoundNonSkip) {
>DiscardUntilEndOfDirective();
>  } else {
> -  const SourceLocation CondBegin =
> CurPPLexer->getSourceLocation();
>// Restore the value of LexingRawMode so that identifiers are
>// looked up, etc, inside the #elif expression.
>assert(CurPPLexer->LexingRawMode && "We have to be skipping
> here!");
>CurPPLexer->LexingRawMode = false;
>IdentifierInfo *IfNDefMacro = nullptr;
> -  const bool CondValue =
> EvaluateDirectiveExpression(IfNDefMacro).Conditional;
> +  DirectiveEvalResult DER =
> EvaluateDirectiveExpression(IfNDefMacro);
> +  const bool CondValue = DER.Conditional;
>CurPPLexer->LexingRawMode = true;
>if (Callbacks) {
> -const SourceLocation CondEnd =
> CurPPLexer->getSourceLocation();
> -Callbacks->Elif(Tok.getLocation(),
> -SourceRange(CondBegin, CondEnd),
> -(CondValue ? PPCallbacks::CVK_True :
> PPCallbacks::CVK_False), CondInfo.IfLoc);
> +Callbacks->Elif(
> +Tok.getLocation(), DER.ExprRange,
> +(CondValue ? PPCallbacks::CVK_True :
> PPCallbacks::CVK_False),
> +CondInfo.IfLoc);
>}
>// If this condition is true, enter it!
>if (CondValue) {
> @@ -1116,19 +1122,24 @@ void Preprocessor::HandleLineDirective()
>  ; // ok
>else if (StrTok.isNot(tok::string_literal)) {
>  Diag(StrTok, diag::err_pp_line_invalid_filename);
> -return DiscardUntilEndOfDirective();
> +DiscardUntilEndOfDirective();
> +retu

r351210 - Revert "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

2019-01-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Jan 15 09:23:36 2019
New Revision: 351210

URL: http://llvm.org/viewvc/llvm-project?rev=351210&view=rev
Log:
Revert "[X86] Make _xgetbv/_xsetbv on non-windows platforms"

This reverts commit r351160. Breaks building v8.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351210&r1=351209&r2=351210&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Jan 15 09:23:36 2019
@@ -693,10 +693,6 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
-TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
-TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h", ALL_MS_LANGUAGES, 
"")
-TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
-TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
 TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
 TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351210&r1=351209&r2=351210&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jan 15 09:23:36 2019
@@ -9833,9 +9833,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_xsavec:
   case X86::BI__builtin_ia32_xsavec64:
   case X86::BI__builtin_ia32_xsaves:
-  case X86::BI__builtin_ia32_xsaves64:
-  case X86::BI__builtin_ia32_xsetbv:
-  case X86::BI_xsetbv: {
+  case X86::BI__builtin_ia32_xsaves64: {
 Intrinsic::ID ID;
 #define INTRINSIC_X86_XSAVE_ID(NAME) \
 case X86::BI__builtin_ia32_##NAME: \
@@ -9855,10 +9853,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 INTRINSIC_X86_XSAVE_ID(xsavec64);
 INTRINSIC_X86_XSAVE_ID(xsaves);
 INTRINSIC_X86_XSAVE_ID(xsaves64);
-INTRINSIC_X86_XSAVE_ID(xsetbv);
-case X86::BI_xsetbv:
-  ID = Intrinsic::x86_xsetbv;
-  break;
 }
 #undef INTRINSIC_X86_XSAVE_ID
 Value *Mhi = Builder.CreateTrunc(
@@ -9868,9 +9862,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
-  case X86::BI__builtin_ia32_xgetbv:
-  case X86::BI_xgetbv:
-return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);
   case X86::BI__builtin_ia32_storedqudi128_mask:
   case X86::BI__builtin_ia32_storedqusi128_mask:
   case X86::BI__builtin_ia32_storedquhi128_mask:

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=351210&r1=351209&r2=351210&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Tue Jan 15 09:23:36 2019
@@ -378,8 +378,9 @@ _storebe_i64(void * __P, long long __D)
 #include 
 #endif
 
-/* No feature check desired due to internal MSC_VER checks */
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVE__)
 #include 
+#endif
 
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEOPT__)
 #include 

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=351210&r1=351209&r2=351210&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue Jan 15 09:23:36 2019
@@ -200,7 +200,10 @@ __attribute__((__deprecated__("use other
 _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
+static __inline__
 #define _XCR_XFEATURE_ENABLED_MASK 0
+unsigned __int64 __cdecl _xgetbv(unsigned int);
+void __cdecl _xsetbv(unsigned int, unsigned __int64);
 
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
 #ifdef __x86_64__
@@ -536,6 +539,12 @@ __cpuidex(int __info[4], int __level, in
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), 
"=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
+static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS

Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-15 Thread Benjamin Kramer via cfe-commits
I rolled it back for now in r351210, this pattern seems to be quite common
even outside of v8. Let's figure out if we can keep the code working or if
it needs to be fixed all over the place :(

On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer  wrote:

> I'm seeing breakages on v8 with this, it defines its own _xgetbv. Any
> ideas what do do about this?
>
>
> https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36
>
> src/x64/assembler-x64.cc:35:1: error: inline variables are incompatible
> with C++ standards before C++17 [-Werror,-Wc++98-c++11-c++14-compat]
> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
> ^
> include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
> # define V8_INLINE inline __attribute__((always_inline))
>^
> src/x64/assembler-x64.cc:35:41: error: expected ')'
> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
> ^
> src/x64/assembler-x64.cc:35:20: note: to match this '('
> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>^
> lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro '_xgetbv'
> #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
>
> On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ctopper
>> Date: Mon Jan 14 21:03:18 2019
>> New Revision: 351160
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
>> Log:
>> [X86] Make _xgetbv/_xsetbv on non-windows platforms
>>
>> Summary:
>> This patch attempts to redo what was tried in r278783, but was reverted.
>>
>> These intrinsics should be available on non-windows platforms with
>> "xsave" feature check. But on Windows platforms they shouldn't have feature
>> check since that's how MSVC behaves.
>>
>> To accomplish this I've added a MS builtin with no feature check. And a
>> normal gcc builtin with a feature check. When _MSC_VER is not defined
>> _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
>>
>> I've moved the forward declarations from intrin.h to immintrin.h to match
>> the MSDN documentation and used that as the header file for the MS builtin.
>>
>> I'm not super happy with this implementation, and I'm open to suggestions
>> for better ways to do it.
>>
>> Reviewers: rnk, RKSimon, spatel
>>
>> Reviewed By: rnk
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D56686
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> cfe/trunk/lib/Headers/immintrin.h
>> cfe/trunk/lib/Headers/intrin.h
>> cfe/trunk/lib/Headers/xsaveintrin.h
>> cfe/trunk/test/CodeGen/builtins-x86.c
>> cfe/trunk/test/CodeGen/x86_32-xsave.c
>> cfe/trunk/test/CodeGen/x86_64-xsave.c
>> cfe/trunk/test/Headers/ms-intrin.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351160&r1=351159&r2=351160&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jan 14 21:03:18 2019
>> @@ -693,6 +693,10 @@ TARGET_BUILTIN(__builtin_ia32_fxsave, "v
>>  // XSAVE
>>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "n", "xsave")
>>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "n", "xsave")
>> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "n", "xsave")
>> +TARGET_HEADER_BUILTIN(_xgetbv, "UWiUi", "nh", "immintrin.h",
>> ALL_MS_LANGUAGES, "")
>> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "n", "xsave")
>> +TARGET_HEADER_BUILTIN(_xsetbv, "vUiUWi", "nh", "immintrin.h",
>> ALL_MS_LANGUAGES, "")
>>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "n", "xsaveopt")
>>  TARGET_BUILTIN(__builtin_ia32_xrstors, "vv*ULLi", "n", "xsaves")
>>  TARGET_BUILTIN(__builtin_ia32_xsavec, "vv*ULLi", "n", "xsavec")
>>
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351160&r1=351159&r2=351160&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jan 14 21:03:18 2019
>> @@ -9831,7 +9831,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>>case X86::BI__builtin_ia32_xsavec:
>>case X86::BI__builtin_ia32_xsavec64:
>>case X86::BI__builtin_ia32_xsaves:
>> -  case X86::BI__builtin_ia32_xsaves64: {
>> +  case X86::BI__builtin_ia32_xsaves64:
>> +  case X86::BI__builtin_ia32_xsetbv:
>> +  case X86::BI_xsetbv: {
>>  Intrinsic::ID ID;
>>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>>  case X86::BI__builtin_ia32_##NAME: \
>> @@ -9851,6 +9853,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>>  INTRINSIC_X86_XSAVE_ID(xsav

Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-15 Thread Benjamin Kramer via cfe-commits
I think the main issue is that libstdc++ 4.9 includes x86intrin.h
transitively from . That's probably broken with all compilers :(

On Tue, Jan 15, 2019 at 7:31 PM Craig Topper  wrote:

> Does V8 work with gcc which also has _xgetbv? Or is it because I had to
> make _xgetbv a macro to make the patch work?
>
> ~Craig
>
>
> On Tue, Jan 15, 2019 at 9:28 AM Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I rolled it back for now in r351210, this pattern seems to be quite
>> common even outside of v8. Let's figure out if we can keep the code working
>> or if it needs to be fixed all over the place :(
>>
>> On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer 
>> wrote:
>>
>>> I'm seeing breakages on v8 with this, it defines its own _xgetbv. Any
>>> ideas what do do about this?
>>>
>>>
>>> https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36
>>>
>>> src/x64/assembler-x64.cc:35:1: error: inline variables are incompatible
>>> with C++ standards before C++17 [-Werror,-Wc++98-c++11-c++14-compat]
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>> ^
>>> include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
>>> # define V8_INLINE inline __attribute__((always_inline))
>>>^
>>> src/x64/assembler-x64.cc:35:41: error: expected ')'
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>> ^
>>> src/x64/assembler-x64.cc:35:20: note: to match this '('
>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>^
>>> lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro
>>> '_xgetbv'
>>> #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
>>>
>>> On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: ctopper
>>>> Date: Mon Jan 14 21:03:18 2019
>>>> New Revision: 351160
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
>>>> Log:
>>>> [X86] Make _xgetbv/_xsetbv on non-windows platforms
>>>>
>>>> Summary:
>>>> This patch attempts to redo what was tried in r278783, but was reverted.
>>>>
>>>> These intrinsics should be available on non-windows platforms with
>>>> "xsave" feature check. But on Windows platforms they shouldn't have feature
>>>> check since that's how MSVC behaves.
>>>>
>>>> To accomplish this I've added a MS builtin with no feature check. And a
>>>> normal gcc builtin with a feature check. When _MSC_VER is not defined
>>>> _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
>>>>
>>>> I've moved the forward declarations from intrin.h to immintrin.h to
>>>> match the MSDN documentation and used that as the header file for the MS
>>>> builtin.
>>>>
>>>> I'm not super happy with this implementation, and I'm open to
>>>> suggestions for better ways to do it.
>>>>
>>>> Reviewers: rnk, RKSimon, spatel
>>>>
>>>> Reviewed By: rnk
>>>>
>>>> Subscribers: cfe-commits
>>>>
>>>> Differential Revision: https://reviews.llvm.org/D56686
>>>>
>>>> Modified:
>>>> cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>>> cfe/trunk/lib/Headers/immintrin.h
>>>> cfe/trunk/lib/Headers/intrin.h
>>>> cfe/trunk/lib/Headers/xsaveintrin.h
>>>> cfe/trunk/test/CodeGen/builtins-x86.c
>>>> cfe/trunk/test/CodeGen/x86_32-xsave.c
>>>> cfe/trunk/test/CodeGen/x86_64-xsave.c
>>>> cfe/trunk/test/Headers/ms-intrin.cpp
>>>>
>>>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=351160&r1=351159&r2=351160&view=diff
>>>>
>>>> ==
>>>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>>>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jan 14 21:03:18
>>>> 2019
>>>> @@ -693,6 +693,10 @@ TARGET_

Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-15 Thread Benjamin Kramer via cfe-commits
I think the only viable solution is to make v8 not define reserved
identifiers & reland this change. That will take some time, so unless this
is blocking something important I'd prefer to reland after the release cut
so the world can catch up before the next release. I can take care of
sending v8 a patch if nobody else feels like doing it.

On Tue, Jan 15, 2019 at 11:28 PM Craig Topper 
wrote:

> any suggestions on how to proceed here?
>
> ~Craig
>
>
> On Tue, Jan 15, 2019 at 10:56 AM Benjamin Kramer 
> wrote:
>
>> I think the main issue is that libstdc++ 4.9 includes x86intrin.h
>> transitively from . That's probably broken with all compilers :(
>>
>> On Tue, Jan 15, 2019 at 7:31 PM Craig Topper 
>> wrote:
>>
>>> Does V8 work with gcc which also has _xgetbv? Or is it because I had to
>>> make _xgetbv a macro to make the patch work?
>>>
>>> ~Craig
>>>
>>>
>>> On Tue, Jan 15, 2019 at 9:28 AM Benjamin Kramer via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> I rolled it back for now in r351210, this pattern seems to be quite
>>>> common even outside of v8. Let's figure out if we can keep the code working
>>>> or if it needs to be fixed all over the place :(
>>>>
>>>> On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer 
>>>> wrote:
>>>>
>>>>> I'm seeing breakages on v8 with this, it defines its own _xgetbv. Any
>>>>> ideas what do do about this?
>>>>>
>>>>>
>>>>> https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36
>>>>>
>>>>> src/x64/assembler-x64.cc:35:1: error: inline variables are
>>>>> incompatible with C++ standards before C++17
>>>>> [-Werror,-Wc++98-c++11-c++14-compat]
>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>> ^
>>>>> include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
>>>>> # define V8_INLINE inline __attribute__((always_inline))
>>>>>^
>>>>> src/x64/assembler-x64.cc:35:41: error: expected ')'
>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>> ^
>>>>> src/x64/assembler-x64.cc:35:20: note: to match this '('
>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>>^
>>>>> lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro
>>>>> '_xgetbv'
>>>>> #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
>>>>>
>>>>> On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>> Author: ctopper
>>>>>> Date: Mon Jan 14 21:03:18 2019
>>>>>> New Revision: 351160
>>>>>>
>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
>>>>>> Log:
>>>>>> [X86] Make _xgetbv/_xsetbv on non-windows platforms
>>>>>>
>>>>>> Summary:
>>>>>> This patch attempts to redo what was tried in r278783, but was
>>>>>> reverted.
>>>>>>
>>>>>> These intrinsics should be available on non-windows platforms with
>>>>>> "xsave" feature check. But on Windows platforms they shouldn't have 
>>>>>> feature
>>>>>> check since that's how MSVC behaves.
>>>>>>
>>>>>> To accomplish this I've added a MS builtin with no feature check. And
>>>>>> a normal gcc builtin with a feature check. When _MSC_VER is not defined
>>>>>> _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
>>>>>>
>>>>>> I've moved the forward declarations from intrin.h to immintrin.h to
>>>>>> match the MSDN documentation and used that as the header file for the MS
>>>>>> builtin.
>>>>>>
>>>>>> I'm not super happy with this implementation, and I'm open to
>>>>>> suggestions for better ways to do it.
>>>>>>
>>>>>> Reviewers: rnk, RKSimon, spatel
>>>>>>
>>>>>> Reviewed By: rnk
>>>>>>
>>>>>> Subscribers: cfe-commits
>>

Re: r351160 - [X86] Make _xgetbv/_xsetbv on non-windows platforms

2019-01-16 Thread Benjamin Kramer via cfe-commits
v8 is fixed, feel free to land this after the release branch :)

On Wed, Jan 16, 2019 at 12:57 AM Craig Topper 
wrote:

> This isn't blocking anything. Just doing some archaeology because I
> noticed we had an intrinsic in the backend, but it wasn't used by the
> frontend due to a previous revert a couple years ago.
>
> ~Craig
>
>
> On Tue, Jan 15, 2019 at 3:47 PM Benjamin Kramer 
> wrote:
>
>> I think the only viable solution is to make v8 not define reserved
>> identifiers & reland this change. That will take some time, so unless this
>> is blocking something important I'd prefer to reland after the release cut
>> so the world can catch up before the next release. I can take care of
>> sending v8 a patch if nobody else feels like doing it.
>>
>> On Tue, Jan 15, 2019 at 11:28 PM Craig Topper 
>> wrote:
>>
>>> any suggestions on how to proceed here?
>>>
>>> ~Craig
>>>
>>>
>>> On Tue, Jan 15, 2019 at 10:56 AM Benjamin Kramer 
>>> wrote:
>>>
>>>> I think the main issue is that libstdc++ 4.9 includes x86intrin.h
>>>> transitively from . That's probably broken with all compilers :(
>>>>
>>>> On Tue, Jan 15, 2019 at 7:31 PM Craig Topper 
>>>> wrote:
>>>>
>>>>> Does V8 work with gcc which also has _xgetbv? Or is it because I had
>>>>> to make _xgetbv a macro to make the patch work?
>>>>>
>>>>> ~Craig
>>>>>
>>>>>
>>>>> On Tue, Jan 15, 2019 at 9:28 AM Benjamin Kramer via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>> I rolled it back for now in r351210, this pattern seems to be quite
>>>>>> common even outside of v8. Let's figure out if we can keep the code 
>>>>>> working
>>>>>> or if it needs to be fixed all over the place :(
>>>>>>
>>>>>> On Tue, Jan 15, 2019 at 3:02 PM Benjamin Kramer 
>>>>>> wrote:
>>>>>>
>>>>>>> I'm seeing breakages on v8 with this, it defines its own _xgetbv.
>>>>>>> Any ideas what do do about this?
>>>>>>>
>>>>>>>
>>>>>>> https://chromium.googlesource.com/v8/v8.git/+/master/src/x64/assembler-x64.cc#36
>>>>>>>
>>>>>>> src/x64/assembler-x64.cc:35:1: error: inline variables are
>>>>>>> incompatible with C++ standards before C++17
>>>>>>> [-Werror,-Wc++98-c++11-c++14-compat]
>>>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>>>> ^
>>>>>>> include/v8config.h:294:20: note: expanded from macro 'V8_INLINE'
>>>>>>> # define V8_INLINE inline __attribute__((always_inline))
>>>>>>>^
>>>>>>> src/x64/assembler-x64.cc:35:41: error: expected ')'
>>>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>>>> ^
>>>>>>> src/x64/assembler-x64.cc:35:20: note: to match this '('
>>>>>>> V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
>>>>>>>^
>>>>>>> lib/clang/include/xsaveintrin.h:49:53: note: expanded from macro
>>>>>>> '_xgetbv'
>>>>>>> #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A))
>>>>>>>
>>>>>>> On Tue, Jan 15, 2019 at 6:06 AM Craig Topper via cfe-commits <
>>>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>>>
>>>>>>>> Author: ctopper
>>>>>>>> Date: Mon Jan 14 21:03:18 2019
>>>>>>>> New Revision: 351160
>>>>>>>>
>>>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=351160&view=rev
>>>>>>>> Log:
>>>>>>>> [X86] Make _xgetbv/_xsetbv on non-windows platforms
>>>>>>>>
>>>>>>>> Summary:
>>>>>>>> This patch attempts to redo what was tried in r278783, but was
>>>>>>>> reverted.
>>>>>>>>
>>>>>>>> These intrinsics should be available on non-windows platforms with
>>>>>>>> "xsave" feature check. But on Windows pl

Re: r345833 - Logging: add CMake dependency so libAST can use OSLog analysis.

2018-11-01 Thread Benjamin Kramer via cfe-commits
This doesn't work. AST cannot depend on Analysis because Analysis already
depends on AST.

On Thu, Nov 1, 2018 at 3:24 PM Tim Northover via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: tnorthover
> Date: Thu Nov  1 07:22:20 2018
> New Revision: 345833
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345833&view=rev
> Log:
> Logging: add CMake dependency so libAST can use OSLog analysis.
>
> Should fix bots on platforms with slightly different symbol resolution
> semantics.
>
> Modified:
> cfe/trunk/lib/AST/CMakeLists.txt
>
> Modified: cfe/trunk/lib/AST/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345833&r1=345832&r2=345833&view=diff
>
> ==
> --- cfe/trunk/lib/AST/CMakeLists.txt (original)
> +++ cfe/trunk/lib/AST/CMakeLists.txt Thu Nov  1 07:22:20 2018
> @@ -1,4 +1,5 @@
>  set(LLVM_LINK_COMPONENTS
> +  Analysis
>BinaryFormat
>Support
>)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346130 - Reapply "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"

2018-11-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Nov  5 04:46:02 2018
New Revision: 346130

URL: http://llvm.org/viewvc/llvm-project?rev=346130&view=rev
Log:
Reapply "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"

This reverts commit r345963. We have a path forward now.

Original commit message:
The driver accidentally stopped passing the input filenames on to -cc1
in this mode due to confusion over what action was being requested.

This change also fixes a couple of crashes I encountered when passing
multiple files to such a -cc1 invocation.

Added:
cfe/trunk/test/Modules/strict-decluse-headers.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Driver/header-module.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=346130&r1=346129&r2=346130&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Nov  5 04:46:02 2018
@@ -3250,18 +3250,15 @@ void Clang::ConstructJob(Compilation &C,
   bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
   bool IsHIP = JA.isOffloading(Action::OFK_HIP);
   bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
-  bool IsModulePrecompile =
-  isa(JA) && JA.getType() == types::TY_ModuleFile;
   bool IsHeaderModulePrecompile = isa(JA);
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
-  // FIXME: Pick the language based on the header file language.
   const char *ModuleName = [&]{
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
-  InputInfo HeaderModuleInput(types::TY_CXXModule, ModuleName, ModuleName);
+  InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName);
 
   const InputInfo &Input =
   IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0];
@@ -3272,10 +3269,9 @@ void Clang::ConstructJob(Compilation &C,
   for (const InputInfo &I : Inputs) {
 if (&I == &Input) {
   // This is the primary input.
-} else if (IsModulePrecompile &&
+} else if (IsHeaderModulePrecompile &&
types::getPrecompiledType(I.getType()) == types::TY_PCH) {
-  types::ID Expected =
-  types::lookupHeaderTypeForSourceType(Inputs[0].getType());
+  types::ID Expected = HeaderModuleInput.getType();
   if (I.getType() != Expected) {
 D.Diag(diag::err_drv_module_header_wrong_kind)
 << I.getFilename() << types::getTypeName(I.getType())

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=346130&r1=346129&r2=346130&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Nov  5 04:46:02 2018
@@ -372,6 +372,9 @@ static void InitializeFileRemapping(Diag
 void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
   const PreprocessorOptions &PPOpts = getPreprocessorOpts();
 
+  // The module manager holds a reference to the old preprocessor (if any).
+  ModuleManager.reset();
+
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = nullptr;
   if (!PPOpts.TokenCache.empty())

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=346130&r1=346129&r2=346130&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon Nov  5 04:46:02 2018
@@ -523,7 +523,7 @@ void ModuleMap::diagnoseHeaderInclusion(
 
   // At this point, only non-modular includes remain.
 
-  if (LangOpts.ModulesStrictDeclUse) {
+  if (RequestingModule && LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
 << RequestingModule->getTopLevelModule()->Name << Filename;
   } else if (RequestingModule && RequestingModuleIsModuleInterface &&

Modified: cfe/trunk/test/Driver/header-module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/header-module.cpp?rev=346130&r1=346129&r2=346130&view=diff
==
--- cfe/trunk/test/Driver/header-module.cpp (original)
+++ cfe/trunk/test/Driver/header-module.cpp Mon Nov  5 04:46:02 2018
@@ -7,7 +7,18 @@
 // CHECK-PRECOMPILE-SAME: -fno-implicit-modules
 // CHECK-PRECOMPILE-SAME: -fmodule-name=foobar
 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
-// CHECK-PRECOMPILE-SAME: -x c++
+// CHECK-PRECOMPILE-SAME: -x c++-header
 // 

[clang-tools-extra] r346608 - [clangd] Make ClangdFuzzer compile again.

2018-11-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Nov 11 03:09:58 2018
New Revision: 346608

URL: http://llvm.org/viewvc/llvm-project?rev=346608&view=rev
Log:
[clangd] Make ClangdFuzzer compile again.

Modified:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp

Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=346608&r1=346607&r2=346608&view=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Sun Nov 11 03:09:58 
2018
@@ -19,20 +19,23 @@
 #include 
 #include 
 
+using namespace clang::clangd;
+
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   if (size == 0)
 return 0;
 
-  clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(),
-clang::clangd::Logger::Error, nullptr);
-  clang::clangd::CodeCompleteOptions CCOpts;
+  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
+  std::FILE *In = fmemopen(data, size, "r");
+  auto Transport = newJSONTransport(In, llvm::nulls(),
+/*InMirror=*/nullptr, /*Pretty=*/false,
+/*Style=*/JSONStreamStyle::Standard);
+  CodeCompleteOptions CCOpts;
   CCOpts.EnableSnippets = false;
-  clang::clangd::ClangdServer::Options Opts;
+  ClangdServer::Options Opts;
 
   // Initialize and run ClangdLSPServer.
-  clang::clangd::ClangdLSPServer LSPServer(Out, CCOpts, llvm::None, false,
-   Opts);
-  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
-  LSPServer.run(fmemopen(data, size, "r"));
+  ClangdLSPServer LSPServer(*Transport, CCOpts, llvm::None, false, Opts);
+  LSPServer.run();
   return 0;
 }


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


Re: r347189 - [OpenCL] Fix address space deduction in template args.

2018-11-19 Thread Benjamin Kramer via cfe-commits
clang gives me this:

llvm/tools/clang/lib/Sema/SemaType.cpp:7230:11: error: variable 'ImpAddr'
is used uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
  if (D.getContext() == DeclaratorContext::TemplateArgContext) {
  ^~~
llvm/tools/clang/lib/Sema/SemaType.cpp:7244:55: note: uninitialized use
occurs here
  T = State.getSema().Context.getAddrSpaceQualType(T, ImpAddr);
  ^~~
llvm/tools/clang/lib/Sema/SemaType.cpp:7230:7: note: remove the 'if' if its
condition is always false
  if (D.getContext() == DeclaratorContext::TemplateArgContext) {
  ^~
llvm/tools/clang/lib/Sema/SemaType.cpp:7208:3: note: variable 'ImpAddr' is
declared here
  LangAS ImpAddr;

On Mon, Nov 19, 2018 at 12:02 PM Anastasia Stulova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: stulova
> Date: Mon Nov 19 03:00:14 2018
> New Revision: 347189
>
> URL: http://llvm.org/viewvc/llvm-project?rev=347189&view=rev
> Log:
> [OpenCL] Fix address space deduction in template args.
>
> Don't deduce address spaces for non-pointer-like types
> in template args.
>
> Fixes PR38603!
>
> Differential Revision: https://reviews.llvm.org/D54634
>
>
> Added:
> cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl
> Modified:
> cfe/trunk/lib/Sema/SemaType.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=347189&r1=347188&r2=347189&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Mon Nov 19 03:00:14 2018
> @@ -7227,7 +7227,9 @@ static void deduceOpenCLImplicitAddrSpac
>  if (IsPointee) {
>ImpAddr = LangAS::opencl_generic;
>  } else {
> -  if (D.getContext() == DeclaratorContext::FileContext) {
> +  if (D.getContext() == DeclaratorContext::TemplateArgContext) {
> +// Do not deduce address space for non-pointee type in template
> args
> +  } else if (D.getContext() == DeclaratorContext::FileContext) {
>  ImpAddr = LangAS::opencl_global;
>} else {
>  if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static
> ||
>
> Added: cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl?rev=347189&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl (added)
> +++ cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl Mon Nov 19
> 03:00:14 2018
> @@ -0,0 +1,31 @@
> +// RUN: %clang_cc1 -cl-std=c++ %s -emit-llvm -o - -O0 -triple
> spir-unknown-unknown | FileCheck %s
> +
> +template 
> +struct S{
> +  T a;
> +  T foo();
> +};
> +
> +template
> +T S::foo() { return a;}
> +
> +//CHECK: %struct.S = type { i32 }
> +//CHECK: %struct.S.0 = type { i32 addrspace(4)* }
> +//CHECK: %struct.S.1 = type { i32 addrspace(1)* }
> +
> +//CHECK: i32 @_ZN1SIiE3fooEv(%struct.S* %this)
> +//CHECK: i32 addrspace(4)* @_ZN1SIPU3AS4iE3fooEv(%struct.S.0* %this)
> +//CHECK: i32 addrspace(1)* @_ZN1SIPU3AS1iE3fooEv(%struct.S.1* %this)
> +
> +void bar(){
> +  S sint;
> +  S sintptr;
> +  S<__global int*> sintptrgl;
> +  // FIXME: Preserve AS in TreeTransform
> +  //S<__global int> sintgl;
> +
> +  sint.foo();
> +  sintptr.foo();
> +  sintptrgl.foo();
> +  //sintgl.foo();
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r347460 - [clangd] Fix use-after-scope in unit test

2018-11-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Nov 22 04:54:25 2018
New Revision: 347460

URL: http://llvm.org/viewvc/llvm-project?rev=347460&view=rev
Log:
[clangd] Fix use-after-scope in unit test

The scheduler holds a reference to `Proceed`, so it has to be destroyed
after the scheduler. Found by asan.

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

Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=347460&r1=347459&r2=347460&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Thu Nov 22 
04:54:25 2018
@@ -221,6 +221,7 @@ TEST_F(TUSchedulerTests, Cancellation) {
   //R3   <-- cancelled
   std::vector DiagsSeen, ReadsSeen, ReadsCanceled;
   {
+Notification Proceed; // Ensure we schedule everything.
 TUScheduler S(
 getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
 /*ASTCallbacks=*/nullptr,
@@ -255,7 +256,6 @@ TEST_F(TUSchedulerTests, Cancellation) {
   return std::move(T.second);
 };
 
-Notification Proceed; // Ensure we schedule everything.
 S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
  [&](std::vector Diags) { Proceed.wait(); });
 // The second parens indicate cancellation, where present.


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


[clang-tools-extra] r347496 - Remove the optional dependency from libclang to clang-tidy/include-fixer

2018-11-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Nov 23 07:02:33 2018
New Revision: 347496

URL: http://llvm.org/viewvc/llvm-project?rev=347496&view=rev
Log:
Remove the optional dependency from libclang to clang-tidy/include-fixer

clangd does a better job on both of these, so don't slow down everyone's build
for a poorly working libclang feature.

Removed:
clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
Modified:
clang-tools-extra/trunk/test/clang-tidy/basic.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/basic.cpp?rev=347496&r1=347495&r2=347496&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/basic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/basic.cpp Fri Nov 23 07:02:33 2018
@@ -1,5 +1,4 @@
 // RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- | FileCheck %s
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin 
-Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang 
-checks='-*,llvm-namespace-comment' 2>&1 | FileCheck %s
 
 namespace i {
 }

Removed: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp?rev=347495&view=auto
==
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (removed)
@@ -1,25 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin 
-Xclang clang-include-fixer -fspell-checking -Xclang 
-plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 
| FileCheck %s
-
-foo f;
-foo g;
-unknown u;
-
-// CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 
'foo'?
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo"
-// CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the 
missing declaration [clang-include-fixer]
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Insert "#include "foo.h"
-// CHECK: yamldb_plugin.cpp:5:1: error: unknown type name 'foo'; did you mean 
'foo'?
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [5:1 - 5:4] with "foo"
-// CHECK: yamldb_plugin.cpp:5:1: note: Add '#include "foo.h"' to provide the 
missing declaration [clang-include-fixer]
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Insert "#include "foo.h"
-// CHECK: " at 4:1
-// CHECK: yamldb_plugin.cpp:6:1:
-// CHECK: error: unknown type name 'unknown'
-// CHECK: Number FIX-ITs = 0
-// CHECK-NOT: error
-// CHECK-NOT: FIX-IT


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


r347496 - Remove the optional dependency from libclang to clang-tidy/include-fixer

2018-11-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Nov 23 07:02:33 2018
New Revision: 347496

URL: http://llvm.org/viewvc/llvm-project?rev=347496&view=rev
Log:
Remove the optional dependency from libclang to clang-tidy/include-fixer

clangd does a better job on both of these, so don't slow down everyone's build
for a poorly working libclang feature.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=347496&r1=347495&r2=347496&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 23 07:02:33 2018
@@ -8938,16 +8938,3 @@ cxindex::Logger::~Logger() {
 OS << "--\n";
   }
 }
-
-#ifdef CLANG_TOOL_EXTRA_BUILD
-// This anchor is used to force the linker to link the clang-tidy plugin.
-extern volatile int ClangTidyPluginAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
-ClangTidyPluginAnchorSource;
-
-// This anchor is used to force the linker to link the clang-include-fixer
-// plugin.
-extern volatile int ClangIncludeFixerPluginAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ClangIncludeFixerPluginAnchorDestination =
-ClangIncludeFixerPluginAnchorSource;
-#endif

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=347496&r1=347495&r2=347496&view=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Fri Nov 23 07:02:33 2018
@@ -47,15 +47,6 @@ if (CLANG_ENABLE_ARCMT)
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
-if (TARGET clangTidyPlugin)
-  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
-  list(APPEND LIBS clangTidyPlugin)
-  list(APPEND LIBS clangIncludeFixerPlugin)
-  if(LLVM_ENABLE_MODULES)
-list(APPEND LLVM_COMPILE_FLAGS 
"-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
-  endif()
-endif ()
-
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)


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


r355816 - [Serialization] Add missing include

2019-03-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Mar 11 03:30:51 2019
New Revision: 355816

URL: http://llvm.org/viewvc/llvm-project?rev=355816&view=rev
Log:
[Serialization] Add missing include

forward decl is not sufficient for destroying a unique_ptr.

Modified:
cfe/trunk/include/clang/Serialization/InMemoryModuleCache.h

Modified: cfe/trunk/include/clang/Serialization/InMemoryModuleCache.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/InMemoryModuleCache.h?rev=355816&r1=355815&r2=355816&view=diff
==
--- cfe/trunk/include/clang/Serialization/InMemoryModuleCache.h (original)
+++ cfe/trunk/include/clang/Serialization/InMemoryModuleCache.h Mon Mar 11 
03:30:51 2019
@@ -12,12 +12,9 @@
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include 
 
-namespace llvm {
-class MemoryBuffer;
-} // end namespace llvm
-
 namespace clang {
 
 /// In-memory cache for modules.


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


r355819 - Remove an unnecessary -f when cp'ing to a file that was just deleted. NFC.

2019-03-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Mar 11 03:44:10 2019
New Revision: 355819

URL: http://llvm.org/viewvc/llvm-project?rev=355819&view=rev
Log:
Remove an unnecessary -f when cp'ing to a file that was just deleted. NFC.

Modified:
cfe/trunk/test/Modules/relative-import-path.c

Modified: cfe/trunk/test/Modules/relative-import-path.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-import-path.c?rev=355819&r1=355818&r2=355819&view=diff
==
--- cfe/trunk/test/Modules/relative-import-path.c (original)
+++ cfe/trunk/test/Modules/relative-import-path.c Mon Mar 11 03:44:10 2019
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: cp -rf %S/Inputs/relative-import-path %t
+// RUN: cp -r %S/Inputs/relative-import-path %t
 // RUN: cp %s %t/t.c
 
 // Use FileCheck, which is more flexible.


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


r356250 - Make getFullyQualifiedName qualify both the pointee and class type for member ptr types

2019-03-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Mar 15 04:09:41 2019
New Revision: 356250

URL: http://llvm.org/viewvc/llvm-project?rev=356250&view=rev
Log:
Make getFullyQualifiedName qualify both the pointee and class type for member 
ptr types

We already handle pointers and references, member ptrs are just another
special case. Fixes PR40732.

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

Modified:
cfe/trunk/lib/AST/QualTypeNames.cpp
cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp

Modified: cfe/trunk/lib/AST/QualTypeNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/QualTypeNames.cpp?rev=356250&r1=356249&r2=356250&view=diff
==
--- cfe/trunk/lib/AST/QualTypeNames.cpp (original)
+++ cfe/trunk/lib/AST/QualTypeNames.cpp Fri Mar 15 04:09:41 2019
@@ -379,6 +379,19 @@ QualType getFullyQualifiedType(QualType
 return QT;
   }
 
+  if (auto *MPT = dyn_cast(QT.getTypePtr())) {
+// Get the qualifiers.
+Qualifiers Quals = QT.getQualifiers();
+// Fully qualify the pointee and class types.
+QT = getFullyQualifiedType(QT->getPointeeType(), Ctx, WithGlobalNsPrefix);
+QualType Class = getFullyQualifiedType(QualType(MPT->getClass(), 0), Ctx,
+   WithGlobalNsPrefix);
+QT = Ctx.getMemberPointerType(QT, Class.getTypePtr());
+// Add back the qualifiers.
+QT = Ctx.getQualifiedType(QT, Quals);
+return QT;
+  }
+
   // In case of myType& we need to strip the reference first, fully
   // qualify and attach the reference once again.
   if (isa(QT.getTypePtr())) {

Modified: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp?rev=356250&r1=356249&r2=356250&view=diff
==
--- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Fri Mar 15 04:09:41 2019
@@ -194,6 +194,7 @@ TEST(QualTypeNameTest, getFullyQualified
   GlobalNsPrefix.ExpectedQualTypeNames["ZVal"] = "::A::B::Y::Z";
   GlobalNsPrefix.ExpectedQualTypeNames["GlobalZVal"] = "::Z";
   GlobalNsPrefix.ExpectedQualTypeNames["CheckK"] = "D::aStruct";
+  GlobalNsPrefix.ExpectedQualTypeNames["YZMPtr"] = "::A::B::X ::A::B::Y::Z::*";
   GlobalNsPrefix.runOver(
   "namespace A {\n"
   "  namespace B {\n"
@@ -205,8 +206,9 @@ TEST(QualTypeNameTest, getFullyQualified
   "template \n"
   "using Alias = CCC;\n"
   "Alias IntAliasVal;\n"
-  "struct Y { struct Z {}; };\n"
+  "struct Y { struct Z { X YZIPtr; }; };\n"
   "Y::Z ZVal;\n"
+  "X Y::Z::*YZMPtr;\n"
   "  }\n"
   "}\n"
   "struct Z {};\n"


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


r357187 - Make helper functions static. NFC.

2019-03-28 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Mar 28 10:18:42 2019
New Revision: 357187

URL: http://llvm.org/viewvc/llvm-project?rev=357187&view=rev
Log:
Make helper functions static. NFC.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=357187&r1=357186&r2=357187&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Mar 28 10:18:42 2019
@@ -914,9 +914,10 @@ static PassBuilder::OptimizationLevel ma
   }
 }
 
-void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple,
-   const LangOptions &LangOpts,
-   const CodeGenOptions &CodeGenOpts) {
+static void addSanitizersAtO0(ModulePassManager &MPM,
+  const Triple &TargetTriple,
+  const LangOptions &LangOpts,
+  const CodeGenOptions &CodeGenOpts) {
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=357187&r1=357186&r2=357187&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Mar 28 10:18:42 2019
@@ -13352,10 +13352,11 @@ static bool checkMapConflicts(
 
 // Look up the user-defined mapper given the mapper name and mapped type, and
 // build a reference to it.
-ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
- CXXScopeSpec &MapperIdScopeSpec,
- const DeclarationNameInfo &MapperId,
- QualType Type, Expr *UnresolvedMapper) {
+static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
+CXXScopeSpec &MapperIdScopeSpec,
+const DeclarationNameInfo 
&MapperId,
+QualType Type,
+Expr *UnresolvedMapper) {
   if (MapperIdScopeSpec.isInvalid())
 return ExprError();
   // Find all user-defined mappers with the given MapperId.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=357187&r1=357186&r2=357187&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Thu Mar 28 
10:18:42 2019
@@ -161,8 +161,8 @@ const Expr *bugreporter::getDerefExpr(co
 /// are the immediate snapshots of the tracked region's bindings within the
 /// node's respective states but not really checking that these snapshots
 /// actually contain the same set of bindings.
-bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal,
-  const ExplodedNode *RightNode, SVal RightVal) {
+static bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal,
+ const ExplodedNode *RightNode, SVal RightVal) {
   if (LeftVal == RightVal)
 return true;
 


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


r342909 - Fix the type of 1<<31 integer constants.

2018-09-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Sep 24 10:51:15 2018
New Revision: 342909

URL: http://llvm.org/viewvc/llvm-project?rev=342909&view=rev
Log:
Fix the type of 1<<31 integer constants.

Shifting into the sign bit is technically undefined behavior. No known
compiler exploits it though.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/CodeGen/CGBlocks.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Sep 24 10:51:15 2018
@@ -449,7 +449,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const FileInfo &FI) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = false;
@@ -458,7 +458,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = true;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Mon Sep 24 10:51:15 2018
@@ -60,7 +60,7 @@ enum BlockLiteralFlags {
   BLOCK_IS_GLOBAL = (1 << 28),
   BLOCK_USE_STRET = (1 << 29),
   BLOCK_HAS_SIGNATURE  =(1 << 30),
-  BLOCK_HAS_EXTENDED_LAYOUT = (1 << 31)
+  BLOCK_HAS_EXTENDED_LAYOUT = (1u << 31)
 };
 class BlockFlags {
   uint32_t flags;


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


r353705 - Make some helper functions static. NFC.

2019-02-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb 11 06:52:15 2019
New Revision: 353705

URL: http://llvm.org/viewvc/llvm-project?rev=353705&view=rev
Log:
Make some helper functions static. NFC.

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=353705&r1=353704&r2=353705&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Feb 11 06:52:15 2019
@@ -968,8 +968,8 @@ void ResultBuilder::AdjustResultPriority
   }
 }
 
-DeclContext::lookup_result getConstructors(ASTContext &Context,
-   const CXXRecordDecl *Record) {
+static DeclContext::lookup_result getConstructors(ASTContext &Context,
+  const CXXRecordDecl *Record) 
{
   QualType RecordTy = Context.getTypeDeclType(Record);
   DeclarationName ConstructorName =
   Context.DeclarationNames.getCXXConstructorName(

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp?rev=353705&r1=353704&r2=353705&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 (original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 Mon Feb 11 06:52:15 2019
@@ -182,7 +182,7 @@ static Optional findArgIdxOfSy
   return None;
 }
 
-Optional findMetaClassAlloc(const Expr *Callee) {
+static Optional findMetaClassAlloc(const Expr *Callee) {
   if (const auto *ME = dyn_cast(Callee)) {
 if (ME->getMemberDecl()->getNameAsString() != "alloc")
   return None;
@@ -200,8 +200,7 @@ Optional findMetaClassAlloc
   return None;
 }
 
-std::string findAllocatedObjectName(const Stmt *S,
-QualType QT) {
+static std::string findAllocatedObjectName(const Stmt *S, QualType QT) {
   if (const auto *CE = dyn_cast(S))
 if (auto Out = findMetaClassAlloc(CE->getCallee()))
   return *Out;


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


[clang-tools-extra] r312166 - [cppcoreguidelines] Don't rely on SmallPtrSet iteration order.

2017-08-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Aug 30 13:18:40 2017
New Revision: 312166

URL: http://llvm.org/viewvc/llvm-project?rev=312166&view=rev
Log:
[cppcoreguidelines] Don't rely on SmallPtrSet iteration order.

The fixit emission breaks if the iteration order changes and also missed
to emit fixits for some edge cases.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=312166&r1=312165&r2=312166&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Wed Aug 30 13:18:40 2017
@@ -32,22 +32,16 @@ AST_MATCHER(CXXRecordDecl, hasDefaultCon
 }
 
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
-// if the record contains an anonmyous struct). If OneFieldPerUnion is true and
-// the record type (or indirect field) is a union, forEachField will stop after
-// the first field.
+// if the record contains an anonmyous struct).
 template 
-void forEachField(const RecordDecl &Record, const T &Fields,
-  bool OneFieldPerUnion, Func &&Fn) {
+void forEachField(const RecordDecl &Record, const T &Fields, Func &&Fn) {
   for (const FieldDecl *F : Fields) {
 if (F->isAnonymousStructOrUnion()) {
   if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl())
-forEachField(*R, R->fields(), OneFieldPerUnion, Fn);
+forEachField(*R, R->fields(), Fn);
 } else {
   Fn(F);
 }
-
-if (OneFieldPerUnion && Record.isUnion())
-  break;
   }
 }
 
@@ -227,7 +221,7 @@ void getInitializationsInOrder(const CXX
   Decls.emplace_back(Decl);
 }
   }
-  forEachField(ClassDecl, ClassDecl.fields(), false,
+  forEachField(ClassDecl, ClassDecl.fields(),
[&](const FieldDecl *F) { Decls.push_back(F); });
 }
 
@@ -353,7 +347,7 @@ void ProTypeMemberInitCheck::checkMissin
 
   // Gather all fields (direct and indirect) that need to be initialized.
   SmallPtrSet FieldsToInit;
-  forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
+  forEachField(ClassDecl, ClassDecl.fields(), [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
 Context) &&
@@ -379,12 +373,12 @@ void ProTypeMemberInitCheck::checkMissin
   // Collect all fields in order, both direct fields and indirect fields from
   // anonmyous record types.
   SmallVector OrderedFields;
-  forEachField(ClassDecl, ClassDecl.fields(), false,
+  forEachField(ClassDecl, ClassDecl.fields(),
[&](const FieldDecl *F) { OrderedFields.push_back(F); });
 
   // Collect all the fields we need to initialize, including indirect fields.
   SmallPtrSet AllFieldsToInit;
-  forEachField(ClassDecl, FieldsToInit, false,
+  forEachField(ClassDecl, FieldsToInit,
[&](const FieldDecl *F) { AllFieldsToInit.insert(F); });
   if (AllFieldsToInit.empty())
 return;
@@ -404,11 +398,16 @@ void ProTypeMemberInitCheck::checkMissin
   // Collect all fields but only suggest a fix for the first member of unions,
   // as initializing more than one union member is an error.
   SmallPtrSet FieldsToFix;
-  forEachField(ClassDecl, FieldsToInit, true, [&](const FieldDecl *F) {
+  SmallPtrSet UnionsSeen;
+  forEachField(ClassDecl, OrderedFields, [&](const FieldDecl *F) {
+if (!FieldsToInit.count(F))
+  return;
 // Don't suggest fixes for enums because we don't know a good default.
 // Don't suggest fixes for bitfields because in-class initialization is not
 // possible.
-if (!F->getType()->isEnumeralType() && !F->isBitField())
+if (F->getType()->isEnumeralType() || F->isBitField())
+  return;
+if (!F->getParent()->isUnion() || UnionsSeen.insert(F->getParent()).second)
   FieldsToFix.insert(F);
   });
   if (FieldsToFix.empty())

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=312166&r1=312165&r2=312166&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Wed Aug 30 13:18:40 2017
@@ -312,6 +312,19 @@ union PositiveUnion {
   // CHECK-FIXES-NOT: float Y{};

r312186 - [Sema] Make SpecialMemberDecl a PointerIntPair so we can stash it in a SmallPtrSet.

2017-08-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Aug 30 15:51:50 2017
New Revision: 312186

URL: http://llvm.org/viewvc/llvm-project?rev=312186&view=rev
Log:
[Sema] Make SpecialMemberDecl a PointerIntPair so we can stash it in a 
SmallPtrSet.

We have enough spare bits in the alignment of CXXRecordDecl. No
functionality change intended.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=312186&r1=312185&r2=312186&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug 30 15:51:50 2017
@@ -1121,12 +1121,13 @@ public:
 CXXInvalid
   };
 
-  typedef std::pair SpecialMemberDecl;
+  typedef llvm::PointerIntPair
+  SpecialMemberDecl;
 
   /// The C++ special members which we are currently in the process of
   /// declaring. If this process recursively triggers the declaration of the
   /// same special member, we should act as if it is not yet declared.
-  llvm::SmallSet SpecialMembersBeingDeclared;
+  llvm::SmallPtrSet SpecialMembersBeingDeclared;
 
   /// The function definitions which were renamed as part of typo-correction
   /// to match their respective declarations. We want to keep track of them


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


r312336 - std::function -> llvm::function_ref. NFC.

2017-09-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Sep  1 09:51:51 2017
New Revision: 312336

URL: http://llvm.org/viewvc/llvm-project?rev=312336&view=rev
Log:
std::function -> llvm::function_ref. NFC.

Modified:
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=312336&r1=312335&r2=312336&view=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Fri Sep  1 09:51:51 2017
@@ -233,9 +233,9 @@ public:
   ///filtered.
   /// \param Filter The filter function that should return true for all groups
   ///   that should be removed from the list.
-  static void
-  filterGroups(std::vector &CloneGroups,
-   std::function Filter) {
+  static void filterGroups(
+  std::vector &CloneGroups,
+  llvm::function_ref Filter) {
 CloneGroups.erase(
 std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter),
 CloneGroups.end());
@@ -249,7 +249,8 @@ public:
   ///to the same CloneGroup.
   static void splitCloneGroups(
   std::vector &CloneGroups,
-  std::function Compare);
+  llvm::function_ref
+  Compare);
 };
 
 /// This constraint moves clones into clone groups of type II via hashing.

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=312336&r1=312335&r2=312336&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Sep  1 09:51:51 2017
@@ -1521,9 +1521,10 @@ private:
   typedef SmallVector CommaLocsTy;
 
   /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
-  bool ParseExpressionList(SmallVectorImpl &Exprs,
-   SmallVectorImpl &CommaLocs,
-   std::function Completer = nullptr);
+  bool ParseExpressionList(
+  SmallVectorImpl &Exprs,
+  SmallVectorImpl &CommaLocs,
+  llvm::function_ref Completer = llvm::function_ref());
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=312336&r1=312335&r2=312336&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Fri Sep  1 09:51:51 2017
@@ -477,7 +477,8 @@ void MatchingVariablePatternConstraint::
 
 void CloneConstraint::splitCloneGroups(
 std::vector &CloneGroups,
-std::function Compare) {
+llvm::function_ref
+Compare) {
   std::vector Result;
   for (auto &HashGroup : CloneGroups) {
 // Contains all indexes in HashGroup that were already added to a

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=312336&r1=312335&r2=312336&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep  1 09:51:51 2017
@@ -2762,7 +2762,7 @@ ExprResult Parser::ParseFoldExpression(E
 /// \endverbatim
 bool Parser::ParseExpressionList(SmallVectorImpl &Exprs,
  SmallVectorImpl &CommaLocs,
- std::function Completer) {
+ llvm::function_ref Completer) {
   bool SawError = false;
   while (1) {
 if (Tok.is(tok::code_completion)) {


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


r312710 - Fixing incorrectly capitalised regexps.

2017-09-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Sep  7 02:54:03 2017
New Revision: 312710

URL: http://llvm.org/viewvc/llvm-project?rev=312710&view=rev
Log:
Fixing incorrectly capitalised regexps.

Patch by Sam Allen!

Modified:
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/CodeGenCXX/anonymous-union-member-initializer.cpp
cfe/trunk/test/CodeGenCXX/arm64-constructor-return.cpp

Modified: cfe/trunk/test/CodeGen/x86_32-xsave.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-xsave.c?rev=312710&r1=312709&r2=312710&view=diff
==
--- cfe/trunk/test/CodeGen/x86_32-xsave.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-xsave.c Thu Sep  7 02:54:03 2017
@@ -15,57 +15,57 @@ void test() {
   void*  tmp_vp = 0;
 
 #ifdef TEST_XSAVE
-// XSAVE: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 4
-// XSAVE: [[tmp_ULLi_1:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
-// XSAVE: [[high64_1:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_1]], 32
-// XSAVE: [[high32_1:%[0-9a-zA-z]+]] = trunc i64 [[high64_1]] to i32
-// XSAVE: [[low32_1:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
+// XSAVE: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4
+// XSAVE: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSAVE: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 32
+// XSAVE: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i32
+// XSAVE: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
 // XSAVE: call void @llvm.x86.xsave(i8* [[tmp_vp_1]], i32 [[high32_1]], i32 
[[low32_1]])
   (void)__builtin_ia32_xsave(tmp_vp, tmp_ULLi);
 
-// XSAVE: [[tmp_vp_3:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 4
-// XSAVE: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
-// XSAVE: [[high64_3:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_3]], 32
-// XSAVE: [[high32_3:%[0-9a-zA-z]+]] = trunc i64 [[high64_3]] to i32
-// XSAVE: [[low32_3:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_3]] to i32
+// XSAVE: [[tmp_vp_3:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4
+// XSAVE: [[tmp_ULLi_3:%[0-9a-zA-Z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSAVE: [[high64_3:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_3]], 32
+// XSAVE: [[high32_3:%[0-9a-zA-Z]+]] = trunc i64 [[high64_3]] to i32
+// XSAVE: [[low32_3:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_3]] to i32
 // XSAVE: call void @llvm.x86.xrstor(i8* [[tmp_vp_3]], i32 [[high32_3]], i32 
[[low32_3]])
   (void)__builtin_ia32_xrstor(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEOPT
-// XSAVEOPT: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 4
-// XSAVEOPT: [[tmp_ULLi_1:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
-// XSAVEOPT: [[high64_1:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_1]], 32
-// XSAVEOPT: [[high32_1:%[0-9a-zA-z]+]] = trunc i64 [[high64_1]] to i32
-// XSAVEOPT: [[low32_1:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
+// XSAVEOPT: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4
+// XSAVEOPT: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSAVEOPT: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 32
+// XSAVEOPT: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i32
+// XSAVEOPT: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
 // XSAVEOPT: call void @llvm.x86.xsaveopt(i8* [[tmp_vp_1]], i32 [[high32_1]], 
i32 [[low32_1]])
   (void)__builtin_ia32_xsaveopt(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEC
-// XSAVEC: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 4
-// XSAVEC: [[tmp_ULLi_1:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
-// XSAVEC: [[high64_1:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_1]], 32
-// XSAVEC: [[high32_1:%[0-9a-zA-z]+]] = trunc i64 [[high64_1]] to i32
-// XSAVEC: [[low32_1:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
+// XSAVEC: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4
+// XSAVEC: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSAVEC: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 32
+// XSAVEC: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i32
+// XSAVEC: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
 // XSAVEC: call void @llvm.x86.xsavec(i8* [[tmp_vp_1]], i32 [[high32_1]], i32 
[[low32_1]])
   (void)__builtin_ia32_xsavec(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVES
-// XSAVES: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 4
-// XSAVES: [[tmp_ULLi_1:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
-// XSAVES: [[high64_1:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_1]], 32
-// XSAVES: [[high32_1:%[0-9a-zA-z]+]] = trunc i64 [[high64_1]] to i32
-// XSAVES: [[low32_1:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_1]] to i32
+// XSAVES: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load i8*, i8** %tmp_vp, align 4
+// XSAVES: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSAVES: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 

r314066 - Silence unused variable warning in Release builds.

2017-09-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Sep 23 09:08:48 2017
New Revision: 314066

URL: http://llvm.org/viewvc/llvm-project?rev=314066&view=rev
Log:
Silence unused variable warning in Release builds.

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

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=314066&r1=314065&r2=314066&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Sep 23 09:08:48 2017
@@ -1030,6 +1030,7 @@ Value *ScalarExprEmitter::EmitScalarConv
 // Source and destination are both expected to be vectors.
 llvm::Type *SrcElementTy = SrcTy->getVectorElementType();
 llvm::Type *DstElementTy = DstTy->getVectorElementType();
+(void)DstElementTy;
 
 assert(((SrcElementTy->isIntegerTy() &&
  DstElementTy->isIntegerTy()) ||


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


r362062 - [AST] asm goto labels don't have constraints, don't try to copy them.

2019-05-30 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 30 00:21:08 2019
New Revision: 362062

URL: http://llvm.org/viewvc/llvm-project?rev=362062&view=rev
Log:
[AST] asm goto labels don't have constraints, don't try to copy them.

Found by asan.

Modified:
cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=362062&r1=362061&r2=362062&view=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Thu May 30 00:21:08 2019
@@ -483,9 +483,10 @@ void GCCAsmStmt::setOutputsAndInputsAndC
   this->Exprs = new (C) Stmt*[NumExprs];
   std::copy(Exprs, Exprs + NumExprs, this->Exprs);
 
+  unsigned NumConstraints = NumOutputs + NumInputs;
   C.Deallocate(this->Constraints);
-  this->Constraints = new (C) StringLiteral*[NumExprs];
-  std::copy(Constraints, Constraints + NumExprs, this->Constraints);
+  this->Constraints = new (C) StringLiteral*[NumConstraints];
+  std::copy(Constraints, Constraints + NumConstraints, this->Constraints);
 
   C.Deallocate(this->Clobbers);
   this->Clobbers = new (C) StringLiteral*[NumClobbers];
@@ -756,8 +757,9 @@ GCCAsmStmt::GCCAsmStmt(const ASTContext
   Exprs = new (C) Stmt*[NumExprs];
   std::copy(exprs, exprs + NumExprs, Exprs);
 
-  Constraints = new (C) StringLiteral*[NumExprs];
-  std::copy(constraints, constraints + NumExprs, Constraints);
+  unsigned NumConstraints = NumOutputs + NumInputs;
+  Constraints = new (C) StringLiteral*[NumConstraints];
+  std::copy(constraints, constraints + NumConstraints, Constraints);
 
   Clobbers = new (C) StringLiteral*[NumClobbers];
   std::copy(clobbers, clobbers + NumClobbers, Clobbers);


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


Re: r362067 - asm goto: fix out-of-bounds read of Constraints after rC362045

2019-05-30 Thread Benjamin Kramer via cfe-commits
Is this still necessary after r362062?

On Thu, May 30, 2019 at 10:00 AM Fangrui Song via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: maskray
> Date: Thu May 30 01:03:02 2019
> New Revision: 362067
>
> URL: http://llvm.org/viewvc/llvm-project?rev=362067&view=rev
> Log:
> asm goto: fix out-of-bounds read of Constraints after rC362045
>
> When parsing goto labels, Names and Exprs are expanded but Constraints
> is not, this may cause a out-of-bounds read later in:
>
> // GCCAsmStmt::GCCAsmStmt
> // `constraints` has only `NumExprs - NumLabels` elements
>   Constraints = new (C) StringLiteral*[NumExprs];
>   std::copy(constraints, constraints + NumExprs, Constraints);
>
> Modified:
> cfe/trunk/lib/Parse/ParseStmtAsm.cpp
>
> Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=362067&r1=362066&r2=362067&view=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Thu May 30 01:03:02 2019
> @@ -846,6 +846,7 @@ StmtResult Parser::ParseAsmStatement(boo
>ExprResult Res =
>Actions.ActOnAddrLabel(Tok.getLocation(), Tok.getLocation(),
> LD);
>Exprs.push_back(Res.get());
> +  Constraints.emplace_back();
>NumLabels++;
>ConsumeToken();
>if (!TryConsumeToken(tok::comma))
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362597 - Revert "Factor out duplicated code building a MemberExpr and marking it" and "Convert MemberExpr creation and serialization to work the same way as"

2019-06-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jun  5 04:46:57 2019
New Revision: 362597

URL: http://llvm.org/viewvc/llvm-project?rev=362597&view=rev
Log:
Revert "Factor out duplicated code building a MemberExpr and marking it" and 
"Convert MemberExpr creation and serialization to work the same way as"

This reverts commits r362551 and r362563. Crashes during modules selfhost.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362597&r1=362596&r2=362597&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Jun  5 04:46:57 2019
@@ -2735,7 +2735,6 @@ class MemberExpr final
 ASTTemplateKWAndArgsInfo,
 TemplateArgumentLoc> {
   friend class ASTReader;
-  friend class ASTStmtReader;
   friend class ASTStmtWriter;
   friend TrailingObjects;
 
@@ -2770,38 +2769,49 @@ class MemberExpr final
 return MemberExprBits.HasTemplateKWAndArgsInfo;
   }
 
-  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
- ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
- QualType T, ExprValueKind VK, ExprObjectKind OK);
-  MemberExpr(EmptyShell Empty)
-  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
-
 public:
-  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
+  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
+ ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,
+ QualType ty, ExprValueKind VK, ExprObjectKind OK)
+  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
+ base->isValueDependent(), base->isInstantiationDependent(),
+ base->containsUnexpandedParameterPack()),
+Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),
+MemberLoc(NameInfo.getLoc()) {
+assert(memberdecl->getDeclName() == NameInfo.getName());
+MemberExprBits.IsArrow = isarrow;
+MemberExprBits.HasQualifierOrFoundDecl = false;
+MemberExprBits.HasTemplateKWAndArgsInfo = false;
+MemberExprBits.HadMultipleCandidates = false;
+MemberExprBits.OperatorLoc = operatorloc;
+  }
+
+  // NOTE: this constructor should be used only when it is known that
+  // the member name can not provide additional syntactic info
+  // (i.e., source locations for C++ operator names or type source info
+  // for constructors, destructors and conversion operators).
+  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
+ ValueDecl *memberdecl, SourceLocation l, QualType ty,
+ ExprValueKind VK, ExprObjectKind OK)
+  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
+ base->isValueDependent(), base->isInstantiationDependent(),
+ base->containsUnexpandedParameterPack()),
+Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) {
+MemberExprBits.IsArrow = isarrow;
+MemberExprBits.HasQualifierOrFoundDecl = false;
+MemberExprBits.HasTemplateKWAndArgsInfo = false;
+MemberExprBits.HadMultipleCandidates = false;
+MemberExprBits.OperatorLoc = operatorloc;
+  }
+
+  static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow,
 SourceLocation OperatorLoc,
 NestedNameSpecifierLoc QualifierLoc,
-SourceLocation TemplateKWLoc, ValueDecl 
*MemberDecl,
-DeclAccessPair FoundDecl,
+SourceLocation TemplateKWLoc, ValueDecl 
*memberdecl,
+DeclAccessPair founddecl,
 DeclarationNameInfo MemberNameInfo,
-const TemplateArgumentListInfo *TemplateArgs,
-QualType T, ExprValueKind VK, ExprObjectKind OK);
-
-  /// Create an implicit MemberExpr, with no location, qualifier, template
-  /// arguments, and so on.
-  static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
-bool IsArrow, ValueDecl *MemberDecl,
-QualType T, ExprValueKind VK,
-ExprObjectKind OK) {
-return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),
-   

  1   2   3   4   5   6   7   8   9   10   >