[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think it's fair to treat instancetype as an inherited requirement — that is, 
the rules of covariant override always apply, which essentially means that 
overriders of instance-returning methods must also return instancetype whether 
they say so explicitly or not.  But that's what I'd like Doug to weigh in 
about; it's possible there are exceptions to that that affect the analysis here.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790



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


r311065 - Further refactoring of the constant emitter. NFC.

2017-08-16 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Aug 16 22:03:55 2017
New Revision: 311065

URL: http://llvm.org/viewvc/llvm-project?rev=311065=rev
Log:
Further refactoring of the constant emitter.  NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=311065=311064=311065=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Aug 16 22:03:55 2017
@@ -1044,120 +1044,6 @@ public:
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);
   }
-
-public:
-  ConstantAddress EmitLValue(APValue::LValueBase LVBase) {
-if (const ValueDecl *Decl = LVBase.dyn_cast()) {
-  if (Decl->hasAttr())
-return CGM.GetWeakRefReference(Decl);
-  if (const FunctionDecl *FD = dyn_cast(Decl))
-return ConstantAddress(CGM.GetAddrOfFunction(FD), CharUnits::One());
-  if (const VarDecl* VD = dyn_cast(Decl)) {
-// We can never refer to a variable with local storage.
-if (!VD->hasLocalStorage()) {
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  if (VD->isFileVarDecl() || VD->hasExternalStorage())
-return ConstantAddress(CGM.GetAddrOfGlobalVar(VD), Align);
-  else if (VD->isLocalVarDecl()) {
-auto Ptr = CGM.getOrCreateStaticVarDecl(
-*VD, CGM.getLLVMLinkageVarDefinition(VD, 
/*isConstant=*/false));
-return ConstantAddress(Ptr, Align);
-  }
-}
-  }
-  return ConstantAddress::invalid();
-}
-
-Expr *E = const_cast(LVBase.get());
-switch (E->getStmtClass()) {
-default: break;
-case Expr::CompoundLiteralExprClass:
-  return tryEmitGlobalCompoundLiteral(CGM, Emitter.CGF,
-  cast(E));
-case Expr::StringLiteralClass:
-  return CGM.GetAddrOfConstantStringFromLiteral(cast(E));
-case Expr::ObjCEncodeExprClass:
-  return 
CGM.GetAddrOfConstantStringFromObjCEncode(cast(E));
-case Expr::ObjCStringLiteralClass: {
-  ObjCStringLiteral* SL = cast(E);
-  ConstantAddress C =
-  CGM.getObjCRuntime().GenerateConstantString(SL->getString());
-  return C.getElementBitCast(ConvertType(E->getType()));
-}
-case Expr::PredefinedExprClass: {
-  unsigned Type = cast(E)->getIdentType();
-  if (auto CGF = Emitter.CGF) {
-LValue Res = CGF->EmitPredefinedLValue(cast(E));
-return cast(Res.getAddress());
-  } else if (Type == PredefinedExpr::PrettyFunction) {
-return CGM.GetAddrOfConstantCString("top level", ".tmp");
-  }
-
-  return CGM.GetAddrOfConstantCString("", ".tmp");
-}
-case Expr::AddrLabelExprClass: {
-  assert(Emitter.CGF &&
- "Invalid address of label expression outside function.");
-  llvm::Constant *Ptr =
-Emitter.CGF->GetAddrOfLabel(cast(E)->getLabel());
-  Ptr = llvm::ConstantExpr::getBitCast(Ptr, ConvertType(E->getType()));
-  return ConstantAddress(Ptr, CharUnits::One());
-}
-case Expr::CallExprClass: {
-  CallExpr* CE = cast(E);
-  unsigned builtin = CE->getBuiltinCallee();
-  if (builtin !=
-Builtin::BI__builtin___CFStringMakeConstantString &&
-  builtin !=
-Builtin::BI__builtin___NSStringMakeConstantString)
-break;
-  const Expr *Arg = CE->getArg(0)->IgnoreParenCasts();
-  const StringLiteral *Literal = cast(Arg);
-  if (builtin ==
-Builtin::BI__builtin___NSStringMakeConstantString) {
-return CGM.getObjCRuntime().GenerateConstantString(Literal);
-  }
-  // FIXME: need to deal with UCN conversion issues.
-  return CGM.GetAddrOfConstantCFString(Literal);
-}
-case Expr::BlockExprClass: {
-  StringRef FunctionName;
-  if (auto CGF = Emitter.CGF)
-FunctionName = CGF->CurFn->getName();
-  else
-FunctionName = "global";
-
-  // This is not really an l-value.
-  llvm::Constant *Ptr =
-CGM.GetAddrOfGlobalBlock(cast(E), FunctionName);
-  return ConstantAddress(Ptr, CGM.getPointerAlign());
-}
-case Expr::CXXTypeidExprClass: {
-  CXXTypeidExpr *Typeid = cast(E);
-  QualType T;
-  if (Typeid->isTypeOperand())
-T = Typeid->getTypeOperand(CGM.getContext());
-  else
-T = Typeid->getExprOperand()->getType();
-  return ConstantAddress(CGM.GetAddrOfRTTIDescriptor(T),
- CGM.getPointerAlign());
-}
-case Expr::CXXUuidofExprClass: {
-  return CGM.GetAddrOfUuidDescriptor(cast(E));
-}
-case Expr::MaterializeTemporaryExprClass: {
-  MaterializeTemporaryExpr *MTE = cast(E);
-  assert(MTE->getStorageDuration() == SD_Static);
-  SmallVector CommaLHSs;
-  

[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-16 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Thanks Malhar! Committed in r311063.


Repository:
  rL LLVM

https://reviews.llvm.org/D36441



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


[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-16 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311063: [analyzer] Add support for reference counting of 
parameters on the callee side (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D36441?vs=111420=111463#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36441

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/retain-release-inline.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -462,6 +462,7 @@
   ArgEffect getDefaultArgEffect() const { return DefaultArgEffect; }
 
   friend class RetainSummaryManager;
+  friend class RetainCountChecker;
 };
 } // end anonymous namespace
 
@@ -1319,6 +1320,13 @@
   return hasRCAnnotation(FD, "rc_ownership_trusted_implementation");
 }
 
+static bool isGeneralizedObjectRef(QualType Ty) {
+  if (Ty.getAsString().substr(0, 4) == "isl_")
+return true;
+  else
+return false;
+}
+
 //===--===//
 // Summary creation for Selectors.
 //===--===//
@@ -1848,6 +1856,15 @@
 
   class CFRefLeakReport : public CFRefReport {
 const MemRegion* AllocBinding;
+const Stmt *AllocStmt;
+
+// Finds the function declaration where a leak warning for the parameter 'sym' should be raised.
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+// Finds the location where a leak warning for 'sym' should be raised.
+void deriveAllocLocation(CheckerContext , SymbolRef sym);
+// Produces description of a leak warning which is printed on the console.
+void createDescription(CheckerContext , bool GCEnabled, bool IncludeAllocationLine);
+
   public:
 CFRefLeakReport(CFRefBug , const LangOptions , bool GCEnabled,
 const SummaryLogTy , ExplodedNode *n, SymbolRef sym,
@@ -2427,13 +2444,25 @@
   return llvm::make_unique(L, os.str());
 }
 
-CFRefLeakReport::CFRefLeakReport(CFRefBug , const LangOptions ,
- bool GCEnabled, const SummaryLogTy ,
- ExplodedNode *n, SymbolRef sym,
- CheckerContext ,
- bool IncludeAllocationLine)
-  : CFRefReport(D, LOpts, GCEnabled, Log, n, sym, false) {
+void CFRefLeakReport::deriveParamLocation(CheckerContext , SymbolRef sym) {
+  const SourceManager& SMgr = Ctx.getSourceManager();
+
+  if (!sym->getOriginRegion())
+return;
 
+  auto *Region = dyn_cast(sym->getOriginRegion());
+  if (Region) {
+const Decl *PDecl = Region->getDecl();
+if (PDecl && isa(PDecl)) {
+  PathDiagnosticLocation ParamLocation = PathDiagnosticLocation::create(PDecl, SMgr);
+  Location = ParamLocation;
+  UniqueingLocation = ParamLocation;
+  UniqueingDecl = Ctx.getLocationContext()->getDecl();
+}
+  }
+}
+
+void CFRefLeakReport::deriveAllocLocation(CheckerContext ,SymbolRef sym) {
   // Most bug reports are cached at the location where they occurred.
   // With leaks, we want to unique them by the location where they were
   // allocated, and only report a single path.  To do this, we need to find
@@ -2457,8 +2486,12 @@
   // FIXME: This will crash the analyzer if an allocation comes from an
   // implicit call (ex: a destructor call).
   // (Currently there are no such allocations in Cocoa, though.)
-  const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
-  assert(AllocStmt && "Cannot find allocation statement");
+  AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
+
+  if (!AllocStmt) {
+AllocBinding = nullptr;
+return;
+  }
 
   PathDiagnosticLocation AllocLocation =
 PathDiagnosticLocation::createBegin(AllocStmt, SMgr,
@@ -2469,8 +2502,10 @@
   // leaks should be uniqued on the allocation site.
   UniqueingLocation = AllocLocation;
   UniqueingDecl = AllocNode->getLocationContext()->getDecl();
+}
 
-  // Fill in the description of the bug.
+void CFRefLeakReport::createDescription(CheckerContext , bool GCEnabled, bool IncludeAllocationLine) {
+  assert(Location.isValid() && UniqueingDecl && UniqueingLocation.isValid());
   Description.clear();
   llvm::raw_string_ostream os(Description);
   os << "Potential leak ";
@@ -2485,6 +2520,20 @@
   os << " (allocated on line " << SL.getSpellingLineNumber() << ")";
 }
   }
+}
+
+CFRefLeakReport::CFRefLeakReport(CFRefBug , const LangOptions ,
+ bool GCEnabled, const SummaryLogTy ,
+ ExplodedNode *n, SymbolRef sym,
+ CheckerContext ,
+ bool IncludeAllocationLine)
+  : CFRefReport(D, LOpts, 

r311063 - [analyzer] Add support for reference counting of parameters on the callee side

2017-08-16 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Aug 16 21:19:07 2017
New Revision: 311063

URL: http://llvm.org/viewvc/llvm-project?rev=311063=rev
Log:
[analyzer] Add support for reference counting of parameters on the callee side

This commit adds the functionality of performing reference counting on the
callee side for Integer Set Library (ISL) to Clang Static Analyzer's
RetainCountChecker.

Reference counting on the callee side can be extensively used to perform
debugging within a function (For example: Finding leaks on error paths).

Patch by Malhar Thakkar!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release-inline.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=311063=311062=311063=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Wed Aug 16 
21:19:07 2017
@@ -462,6 +462,7 @@ private:
   ArgEffect getDefaultArgEffect() const { return DefaultArgEffect; }
 
   friend class RetainSummaryManager;
+  friend class RetainCountChecker;
 };
 } // end anonymous namespace
 
@@ -1319,6 +1320,13 @@ static bool isTrustedReferenceCountImple
   return hasRCAnnotation(FD, "rc_ownership_trusted_implementation");
 }
 
+static bool isGeneralizedObjectRef(QualType Ty) {
+  if (Ty.getAsString().substr(0, 4) == "isl_")
+return true;
+  else
+return false;
+}
+
 
//===--===//
 // Summary creation for Selectors.
 
//===--===//
@@ -1848,6 +1856,15 @@ namespace {
 
   class CFRefLeakReport : public CFRefReport {
 const MemRegion* AllocBinding;
+const Stmt *AllocStmt;
+
+// Finds the function declaration where a leak warning for the parameter 
'sym' should be raised.
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+// Finds the location where a leak warning for 'sym' should be raised.
+void deriveAllocLocation(CheckerContext , SymbolRef sym);
+// Produces description of a leak warning which is printed on the console.
+void createDescription(CheckerContext , bool GCEnabled, bool 
IncludeAllocationLine);
+
   public:
 CFRefLeakReport(CFRefBug , const LangOptions , bool GCEnabled,
 const SummaryLogTy , ExplodedNode *n, SymbolRef sym,
@@ -2427,13 +2444,25 @@ CFRefLeakReportVisitor::getEndPath(BugRe
   return llvm::make_unique(L, os.str());
 }
 
-CFRefLeakReport::CFRefLeakReport(CFRefBug , const LangOptions ,
- bool GCEnabled, const SummaryLogTy ,
- ExplodedNode *n, SymbolRef sym,
- CheckerContext ,
- bool IncludeAllocationLine)
-  : CFRefReport(D, LOpts, GCEnabled, Log, n, sym, false) {
+void CFRefLeakReport::deriveParamLocation(CheckerContext , SymbolRef sym) {
+  const SourceManager& SMgr = Ctx.getSourceManager();
+
+  if (!sym->getOriginRegion())
+return;
 
+  auto *Region = dyn_cast(sym->getOriginRegion());
+  if (Region) {
+const Decl *PDecl = Region->getDecl();
+if (PDecl && isa(PDecl)) {
+  PathDiagnosticLocation ParamLocation = 
PathDiagnosticLocation::create(PDecl, SMgr);
+  Location = ParamLocation;
+  UniqueingLocation = ParamLocation;
+  UniqueingDecl = Ctx.getLocationContext()->getDecl();
+}
+  }
+}
+
+void CFRefLeakReport::deriveAllocLocation(CheckerContext ,SymbolRef sym) {
   // Most bug reports are cached at the location where they occurred.
   // With leaks, we want to unique them by the location where they were
   // allocated, and only report a single path.  To do this, we need to find
@@ -2457,8 +2486,12 @@ CFRefLeakReport::CFRefLeakReport(CFRefBu
   // FIXME: This will crash the analyzer if an allocation comes from an
   // implicit call (ex: a destructor call).
   // (Currently there are no such allocations in Cocoa, though.)
-  const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
-  assert(AllocStmt && "Cannot find allocation statement");
+  AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
+
+  if (!AllocStmt) {
+AllocBinding = nullptr;
+return;
+  }
 
   PathDiagnosticLocation AllocLocation =
 PathDiagnosticLocation::createBegin(AllocStmt, SMgr,
@@ -2469,8 +2502,10 @@ CFRefLeakReport::CFRefLeakReport(CFRefBu
   // leaks should be uniqued on the allocation site.
   UniqueingLocation = AllocLocation;
   UniqueingDecl = AllocNode->getLocationContext()->getDecl();
+}
 
-  // Fill in the description of the bug.
+void CFRefLeakReport::createDescription(CheckerContext , bool GCEnabled, 
bool 

[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-16 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

@ruiu 
I understand your concern. However by doing this (rather than building 
functions for each flag), we will be able to get all information in OptTable 
itself. It is true that this is quite fragile, but adding ValuesCode to new 
flag is not complicated, so I believe overall it's fine.


https://reviews.llvm.org/D36782



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


[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-16 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111457.
yamaguchi marked 2 inline comments as done.
yamaguchi added a comment.

Update diff.


https://reviews.llvm.org/D36782

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -298,5 +298,30 @@
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
+
+  OS << "\n";
+  OS << "#ifdef OPTTABLE_ARG_INIT\n";
+  OS << "//\n";
+  OS << "// Option Values\n\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
+if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << "{\n";
+  OS << R.getValueAsString("ValuesCode");
+  OS << "\n";
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "bool ValuesWereAdded = ";
+OS << "Opt.addValues(";
+std::string S = (Pref + R.getValueAsString("Name")).str();
+write_cstring(OS, S);
+OS << ", Values);\n";
+OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
+OS << " \"Couldn't add values to OptTable!\");\n";
+  }
+  OS << "}\n";
+}
+  }
+  OS << "\n";
+  OS << "#endif // OPTTABLE_ARG_INIT\n";
 }
 } // end namespace llvm
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -196,7 +196,7 @@
 
 // Returns true if one of the Prefixes + In.Names matches Option
 static bool optionMatches(const OptTable::Info , StringRef Option) {
-  if (In.Values && In.Prefixes)
+  if (In.Prefixes)
 for (size_t I = 0; In.Prefixes[I]; I++)
   if (Option == std::string(In.Prefixes[I]) + In.Name)
 return true;
@@ -209,8 +209,9 @@
 std::vector
 OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
   // Search all options and return possible values.
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
-if (!optionMatches(In, Option))
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
+if (!In.Values || !optionMatches(In, Option))
   continue;
 
 SmallVector Candidates;
@@ -228,7 +229,8 @@
 std::vector
 OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
   std::vector Ret;
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
 if (!In.Prefixes || (!In.HelpText && !In.GroupID))
   continue;
 if (In.Flags & DisableFlags)
@@ -245,6 +247,17 @@
   return Ret;
 }
 
+bool OptTable::addValues(const char *Option, const char *Values) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+Info  = OptionInfos[I];
+if (optionMatches(In, Option)) {
+  In.Values = Values;
+  return true;
+}
+  }
+  return false;
+}
+
 Arg *OptTable::ParseOneArg(const ArgList , unsigned ,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
@@ -256,8 +269,8 @@
   if (isInput(PrefixesUnion, Str))
 return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
 
-  const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
-  const Info *End = OptionInfos.end();
+  const Info *Start = OptionInfos.data() + FirstSearchableIndex;
+  const Info *End = OptionInfos.data() + OptionInfos.size();
   StringRef Name = StringRef(Str).ltrim(PrefixChars);
 
   // Search for the first next option which could be a prefix.
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -57,8 +57,8 @@
   };
 
 private:
-  /// \brief The static option information table.
-  ArrayRef OptionInfos;
+  /// \brief The option information table.
+  std::vector OptionInfos;
   bool IgnoreCase;
 
   unsigned TheInputOptionID = 0;
@@ -143,6 +143,17 @@
   std::vector findByPrefix(StringRef Cur,
 unsigned short DisableFlags) const;
 
+  /// Add Values to Option's Values class
+  ///
+  /// \param [in] Option - Prefix + Name of the flag which Values will be
+  ///  changed. For example, "-analyzer-checker".
+  /// \param [in] Values - String of Values seperated by ",", such as
+  ///  "foo, bar..", where foo and bar is the argument which the Option flag
+  //  takes
+  ///
+  /// \return true in success, and false in fail.
+  bool addValues(const char 

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-16 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 111433.
euhlmann marked 13 inline comments as done.
euhlmann edited the summary of this revision.
euhlmann added a comment.

Allows comments before the include guard opens. However, if there's a single 
non-comment line before an include-guard-like structure that meets all the 
other conditions then it will be treated as an include guard because `Lines` 
does not yet contain the line before the `#ifndef`. This looks difficult to fix 
and I believe it's a rare enough situation to ignore.

This does not yet address avoiding repetition in the tests or comments before 
indented preprocessor lines being indented.


https://reviews.llvm.org/D35955

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2286,8 +2286,206 @@
getLLVMStyleWithColumns(11));
 }
 
-TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
-  EXPECT_EQ("{\n  {\n#define A\n  }\n}", format("{{\n#define A\n}}"));
+TEST_F(FormatTest, FooBar) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  llvm::dbgs() <<
+format("code();\n"
+   "#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"
+   "code();\n"
+   "#endif",
+   Style) << "\n";
+}
+
+TEST_F(FormatTest, IndentPreprocessorDirectives) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef _WIN32\n"
+   "#define A 0\n"
+   "#ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#endif\n"
+   "#else\n"
+   "#define A 1\n"
+   "#endif",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef _WIN32\n"
+   "#  define A 0\n"
+   "#  ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#  endif\n"
+   "#else\n"
+   "#  define A 1\n"
+   "#endif",
+   Style);
+  // Comments before include guard.
+  verifyFormat("// file comment\n"
+   "// file comment\n"
+   "#ifndef HEADER_H\n"
+   "#define HEADER_H\n"
+   "code();\n"
+   "#endif",
+   Style);
+  // Test with include guards.
+  // EXPECT_EQ is used because verifyFormat() calls messUp() which incorrectly
+  // merges lines.
+  EXPECT_EQ("#ifndef HEADER_H\n"
+"#define HEADER_H\n"
+"code();\n"
+"#endif",
+format("#ifndef HEADER_H\n"
+   "#define HEADER_H\n"
+   "code();\n"
+   "#endif",
+   Style));
+  // Include guards must have a #define with the same variable immediately
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"
+"code();\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define FOO\n"
+   "code();\n"
+   "#endif",
+   Style));
+
+  // Include guards must cover the entire file.
+  EXPECT_EQ("code();\n"
+"code();\n"
+"#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif",
+format("code();\n"
+   "code();\n"
+   "#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif\n"
+"code();",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif\n"
+   "code();",
+   Style));
+  // Test with trailing blank lines.
+  EXPECT_EQ("#ifndef 

[PATCH] D36802: AMDGPU: Insert __devicename__ macros

2017-08-16 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: lib/Basic/Targets/AMDGPU.cpp:364-367
+  if (GPUName.empty())
+return;
+
+  Builder.defineMacro(Twine("__") + Twine(GPUName) + Twine("__"));

Should this be the following since extra macros could be after it in the future:

```
if (!GPUName.empty())
  Builder.defineMacro(Twine("__") + Twine(GPUName) + Twine("__"));
```

Should we only be defining macros using the canonical target name (the one in 
column 1 of https://llvm.org/docs/AMDGPUUsage.html#processors) rather than the 
one specified on the command line?


https://reviews.llvm.org/D36802



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


r311053 - [index] Add indexing for unresolved-using declarations

2017-08-16 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Wed Aug 16 16:12:21 2017
New Revision: 311053

URL: http://llvm.org/viewvc/llvm-project?rev=311053=rev
Log:
[index] Add indexing for unresolved-using declarations

In dependent contexts we end up referencing these, so make sure they
have USRs, and have their declarations indexed. For the most part they
behave like typedefs, but we also need to worry about having multiple
using declarations with the same "name".

rdar://problem/33883650

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/index-dependent-source.cpp
cfe/trunk/test/Index/index-templates.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=311053=311052=311053=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Wed Aug 16 16:12:21 2017
@@ -53,6 +53,7 @@ enum class SymbolKind : uint8_t {
   ConversionFunction,
 
   Parameter,
+  Using,
 };
 
 enum class SymbolLanguage {
@@ -69,6 +70,8 @@ enum class SymbolSubKind {
   CXXMoveConstructor,
   AccessorGetter,
   AccessorSetter,
+  UsingTypename,
+  UsingValue,
 };
 
 /// Set of properties that provide additional info about a symbol.

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=311053=311052=311053=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Aug 16 16:12:21 2017
@@ -611,6 +611,24 @@ public:
 SymbolRoleSet());
   }
 
+  bool VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
+TRY_DECL(D, IndexCtx.handleDecl(D));
+const DeclContext *DC = D->getDeclContext()->getRedeclContext();
+const NamedDecl *Parent = dyn_cast(DC);
+IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
+ D->getLexicalDeclContext());
+return true;
+  }
+
+  bool VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) {
+TRY_DECL(D, IndexCtx.handleDecl(D));
+const DeclContext *DC = D->getDeclContext()->getRedeclContext();
+const NamedDecl *Parent = dyn_cast(DC);
+IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
+ D->getLexicalDeclContext());
+return true;
+  }
+
   bool VisitClassTemplateSpecializationDecl(const
ClassTemplateSpecializationDecl *D) 
{
 // FIXME: Notify subsequent callbacks if info comes from implicit

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=311053=311052=311053=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Wed Aug 16 16:12:21 2017
@@ -300,6 +300,18 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::TypeAlias;
   Info.Lang = SymbolLanguage::CXX;
   break;
+case Decl::UnresolvedUsingTypename:
+  Info.Kind = SymbolKind::Using;
+  Info.SubKind = SymbolSubKind::UsingTypename;
+  Info.Lang = SymbolLanguage::CXX;
+  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  break;
+case Decl::UnresolvedUsingValue:
+  Info.Kind = SymbolKind::Using;
+  Info.SubKind = SymbolSubKind::UsingValue;
+  Info.Lang = SymbolLanguage::CXX;
+  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  break;
 case Decl::Binding:
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;
@@ -448,6 +460,7 @@ StringRef index::getSymbolKindString(Sym
   case SymbolKind::Destructor: return "destructor";
   case SymbolKind::ConversionFunction: return "coversion-func";
   case SymbolKind::Parameter: return "param";
+  case SymbolKind::Using: return "using";
   }
   llvm_unreachable("invalid symbol kind");
 }
@@ -459,6 +472,8 @@ StringRef index::getSymbolSubKindString(
   case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
   case SymbolSubKind::AccessorGetter: return "acc-get";
   case SymbolSubKind::AccessorSetter: return "acc-set";
+  case SymbolSubKind::UsingTypename: return "using-typename";
+  case SymbolSubKind::UsingValue: return "using-value";
   }
   llvm_unreachable("invalid symbol subkind");
 }

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=311053=311052=311053=diff

r311051 - Fix typos in comments; NFC

2017-08-16 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Aug 16 15:44:17 2017
New Revision: 311051

URL: http://llvm.org/viewvc/llvm-project?rev=311051=rev
Log:
Fix typos in comments; NFC

Modified:
cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h?rev=311051=311050=311051=diff
==
--- cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h (original)
+++ cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h Wed Aug 16 15:44:17 2017
@@ -92,7 +92,7 @@ public:
 TheMacro = nullptr;
   }
 
-  /// getHasReadAnyTokensVal - This is used for the \#ifndef hande-shake at the
+  /// getHasReadAnyTokensVal - This is used for the \#ifndef handshake at the
   /// top of the file when reading preprocessor directives.  Otherwise, reading
   /// the "ifndef x" would count as reading tokens.
   bool getHasReadAnyTokensVal() const { return ReadAnyTokens; }

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=311051=311050=311051=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug 16 15:44:17 2017
@@ -995,7 +995,7 @@ static QualType handleComplexFloatConver
   return ResultType;
 }
 
-/// \brief Hande arithmetic conversion from integer to float.  Helper function
+/// \brief Handle arithmetic conversion from integer to float.  Helper function
 /// of UsualArithmeticConversions()
 static QualType handleIntToFloatConversion(Sema , ExprResult ,
ExprResult ,


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


[libcxxabi] r311047 - Revert "[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return"

2017-08-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug 16 15:05:54 2017
New Revision: 311047

URL: http://llvm.org/viewvc/llvm-project?rev=311047=rev
Log:
Revert "[libcxxabi] When built with ASan, __cxa_throw calls 
__asan_handle_no_return"

This reverts commit r311045 because it's causing an error on
libcxx-libcxxabi-x86_64-linux-ubuntu-asan bot.

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=311047=311046=311047=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Aug 16 15:05:54 2017
@@ -19,10 +19,6 @@
 #include "cxa_handlers.hpp"
 #include "fallback_malloc.h"
 
-#if __has_feature(address_sanitizer)
-#include 
-#endif
-
 // +---+-+---+
 // | __cxa_exception   | _Unwind_Exception CLNGC++\0 | thrown object |
 // +---+-+---+
@@ -221,12 +217,6 @@ __cxa_throw(void *thrown_object, std::ty
 globals->uncaughtExceptions += 1;   // Not atomically, since globals are 
thread-local
 
 exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
-
-#if __has_feature(address_sanitizer)
-// Inform the ASan runtime that now might be a good time to clean stuff up.
-__asan_handle_no_return();
-#endif
-
 #ifdef __USING_SJLJ_EXCEPTIONS__
 _Unwind_SjLj_RaiseException(_header->unwindHeader);
 #else


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


[libcxxabi] r311045 - [libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return

2017-08-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug 16 14:58:09 2017
New Revision: 311045

URL: http://llvm.org/viewvc/llvm-project?rev=311045=rev
Log:
[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return

The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.

Patch by Roland McGrath

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

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=311045=311044=311045=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Aug 16 14:58:09 2017
@@ -19,6 +19,10 @@
 #include "cxa_handlers.hpp"
 #include "fallback_malloc.h"
 
+#if __has_feature(address_sanitizer)
+#include 
+#endif
+
 // +---+-+---+
 // | __cxa_exception   | _Unwind_Exception CLNGC++\0 | thrown object |
 // +---+-+---+
@@ -217,6 +221,12 @@ __cxa_throw(void *thrown_object, std::ty
 globals->uncaughtExceptions += 1;   // Not atomically, since globals are 
thread-local
 
 exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
+
+#if __has_feature(address_sanitizer)
+// Inform the ASan runtime that now might be a good time to clean stuff up.
+__asan_handle_no_return();
+#endif
+
 #ifdef __USING_SJLJ_EXCEPTIONS__
 _Unwind_SjLj_RaiseException(_header->unwindHeader);
 #else


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


r311043 - Don't use -no-integrated-as in test/Driver/opt-record.c

2017-08-16 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Wed Aug 16 14:51:31 2017
New Revision: 311043

URL: http://llvm.org/viewvc/llvm-project?rev=311043=rev
Log:
Don't use -no-integrated-as in test/Driver/opt-record.c

-no-integrated-as is not supported on some targets (e.g.,
x86_64-pc-windows-msvc). Testing using -save-temps is good enough to cover the
relevant logic, and that should work everywhere.

Modified:
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/test/Driver/opt-record.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opt-record.c?rev=311043=311042=311043=diff
==
--- cfe/trunk/test/Driver/opt-record.c (original)
+++ cfe/trunk/test/Driver/opt-record.c Wed Aug 16 14:51:31 2017
@@ -1,12 +1,9 @@
 // RUN: %clang -### -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
 // RUN: %clang -### -c -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
 // RUN: %clang -### -c -o FOO.o -fsave-optimization-record %s 2>&1 | FileCheck 
%s
-// RUN: %clang -### -no-integrated-as -S -o FOO -fsave-optimization-record %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -no-integrated-as -c -o FOO.o -fsave-optimization-record 
%s 2>&1 | FileCheck %s
 // RUN: %clang -### -save-temps -S -o FOO -fsave-optimization-record %s 2>&1 | 
FileCheck %s
 // RUN: %clang -### -save-temps -c -o FOO.o -fsave-optimization-record %s 2>&1 
| FileCheck %s
 // RUN: %clang -### -c -fsave-optimization-record %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NO-O
-// RUN: %clang -### -no-integrated-as -c -fsave-optimization-record %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-O
 // RUN: %clang -### -save-temps -c -fsave-optimization-record %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-O
 // RUN: %clang -### -fsave-optimization-record %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NO-O
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV


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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-16 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin resigned from this revision.
aheejin added a comment.

I don't have enough context or knowledge on this code base. Sorry!


https://reviews.llvm.org/D36764



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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-16 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

Anyone have any opinions on this?


https://reviews.llvm.org/D36764



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


r311041 - Base optimization-record file names on the final output

2017-08-16 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Wed Aug 16 14:34:27 2017
New Revision: 311041

URL: http://llvm.org/viewvc/llvm-project?rev=311041=rev
Log:
Base optimization-record file names on the final output

Using Output.getFilename() to construct the file name used for optimization
recording in Clang::ConstructJob, when -c is provided, does not work correctly
if we're not using the integrated assembler. With -no-integrated-as (or
-save-temps) Output.getFilename() gives the name of the temporary assembly
file, not the final output file. Instead, use the final output (as provided by
-o). If this is not available, then fall back to using a name based on the
input file.

Fixes PR31532.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=311041=311040=311041=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Aug 16 14:34:27 2017
@@ -4261,10 +4261,13 @@ void Clang::ConstructJob(Compilation ,
   CmdArgs.push_back(A->getValue());
 } else {
   SmallString<128> F;
-  if (Output.isFilename() && (Args.hasArg(options::OPT_c) ||
-  Args.hasArg(options::OPT_S))) {
-F = Output.getFilename();
-  } else {
+
+  if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
+if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
+  F = FinalOutput->getValue();
+  }
+
+  if (F.empty()) {
 // Use the input filename.
 F = llvm::sys::path::stem(Input.getBaseInput());
 

Modified: cfe/trunk/test/Driver/opt-record.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opt-record.c?rev=311041=311040=311041=diff
==
--- cfe/trunk/test/Driver/opt-record.c (original)
+++ cfe/trunk/test/Driver/opt-record.c Wed Aug 16 14:34:27 2017
@@ -1,6 +1,13 @@
 // RUN: %clang -### -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
 // RUN: %clang -### -c -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
+// RUN: %clang -### -c -o FOO.o -fsave-optimization-record %s 2>&1 | FileCheck 
%s
+// RUN: %clang -### -no-integrated-as -S -o FOO -fsave-optimization-record %s 
2>&1 | FileCheck %s
+// RUN: %clang -### -no-integrated-as -c -o FOO.o -fsave-optimization-record 
%s 2>&1 | FileCheck %s
+// RUN: %clang -### -save-temps -S -o FOO -fsave-optimization-record %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### -save-temps -c -o FOO.o -fsave-optimization-record %s 2>&1 
| FileCheck %s
 // RUN: %clang -### -c -fsave-optimization-record %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NO-O
+// RUN: %clang -### -no-integrated-as -c -fsave-optimization-record %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-O
+// RUN: %clang -### -save-temps -c -fsave-optimization-record %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-O
 // RUN: %clang -### -fsave-optimization-record %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-NO-O
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib 
%s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV


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


[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-16 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 111420.
malhar1995 added a comment.

This patch adds the functionality of performing reference counting on the 
callee side for Integer Set Library (ISL) to Clang Static Analyzer's 
RetainCountChecker.

Reference counting on the callee side can be extensively used to perform 
debugging within a function (For example: Finding leaks on error paths).


Repository:
  rL LLVM

https://reviews.llvm.org/D36441

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m

Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -302,6 +302,9 @@
 __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
+void callee_side_parameter_checking_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) { // expected-warning {{Potential leak of an object}}
+}
+
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
@@ -348,6 +351,37 @@
   isl_basic_map_free(bmap);
 }
 
+void callee_side_parameter_checking_incorrect_rc_decrement(isl_basic_map *bmap) {
+  isl_basic_map_free(bmap); // expected-warning {{Incorrect decrement of the reference count}}
+}
+
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_return_notowned_object(isl_basic_map *bmap) {
+  return bmap; // expected-warning {{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
+
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_assign_consumed_parameter_leak_return(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap1, __attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap2) { // expected-warning {{Potential leak of an object}}
+  bmap1 = bmap2;
+  isl_basic_map_free(bmap2);
+  return bmap1;
+}
+
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *callee_side_parameter_checking_assign_consumed_parameter_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap1, __attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap2) { // expected-warning {{Potential leak of an object}}
+  bmap1 = bmap2;
+  isl_basic_map_free(bmap1);
+  return bmap2;
+}
+
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *error_path_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap1, __attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap2) { // expected-warning {{Potential leak of an object}}
+  bmap1 = isl_basic_map_cow(bmap1);
+  if (!bmap1 || !bmap2)
+goto error;
+
+  isl_basic_map_free(bmap2);
+  return bmap1;
+error:
+  return isl_basic_map_free(bmap1);
+}
+
 //===--===//
 // Test returning retained and not-retained values.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -462,6 +462,7 @@
   ArgEffect getDefaultArgEffect() const { return DefaultArgEffect; }
 
   friend class RetainSummaryManager;
+  friend class RetainCountChecker;
 };
 } // end anonymous namespace
 
@@ -1319,6 +1320,13 @@
   return hasRCAnnotation(FD, "rc_ownership_trusted_implementation");
 }
 
+static bool isGeneralizedObjectRef(QualType Ty) {
+  if (Ty.getAsString().substr(0, 4) == "isl_")
+return true;
+  else
+return false;
+}
+
 //===--===//
 // Summary creation for Selectors.
 //===--===//
@@ -1848,6 +1856,15 @@
 
   class CFRefLeakReport : public CFRefReport {
 const MemRegion* AllocBinding;
+const Stmt *AllocStmt;
+
+// Finds the function declaration where a leak warning for the parameter 'sym' should be raised.
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+// Finds the location where a leak warning for 'sym' should be raised.
+void deriveAllocLocation(CheckerContext , SymbolRef sym);
+// Produces description of a leak warning which is printed on the console.
+void createDescription(CheckerContext , bool GCEnabled, bool 

[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-16 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

This patch allows us to embed a piece of C++ code to each command line option 
to construct a list of argument candidates at runtime. With this patch, .inc 
files generated by OptParserEmitter contain C macros that in turn include other 
.inc files. That is a flexible mechanism but can be too flexible and fragile, 
as you can write any code in .td file, and pieces of C++ code you write in .td 
files are not verified even for syntax validation until that nested text 
inclusions are processed by a C++ compiler. It does two-stages of code 
generation, one is done by OptTable and the other is done by C macros. I can 
imagine that a single typo in a .td file can cause a mysterious error that is 
hard to debug. I feel like, even though command line processing is not that 
easy, I wonder if it is that complicated to require two-stage code generation.

That being said, I don't oppose to this patch, as people who know more about 
this code seem to like this approach. I'm just expressing my concern.




Comment at: llvm/include/llvm/Option/OptTable.h:60
 private:
   /// \brief The static option information table.
+  std::vector OptionInfos;

teemperor wrote:
> This is no longer static :)
Just remove "non-static" instead of saying this is non-static, as being 
non-const is not special.


https://reviews.llvm.org/D36782



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


Re: [clang-tools-extra] r311020 - [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Chih-hung Hsieh via cfe-commits
Thanks. The fix is in https://reviews.llvm.org/rL311040.


On Wed, Aug 16, 2017 at 1:39 PM, Evgenii Stepanov  wrote:

> Hi,
>
> this change breaks build:
> clang-tools-extra/clang-tidy/android/CloexecSocketCheck.cpp:20:30:
> error: unused variable 'SOCK_CLOEXEC'
> [-Werror,-Wunused-const-variable]
> static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
>
> Please test with LLVM_ENABLE_WERROR=ON before submitting!
>
>
> On Wed, Aug 16, 2017 at 9:59 AM, Chih-Hung Hsieh via cfe-commits
>  wrote:
> > Author: chh
> > Date: Wed Aug 16 09:59:26 2017
> > New Revision: 311020
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=311020=rev
> > Log:
> > [clang-tidy] Use CloexecCheck as base class.
> >
> > Summary:
> > Simplify registerMatchers and check functions in CloexecCreatCheck,
> > CloexecSocketCheck, CloexecFopenCheck, and CloexecOpenCheck.
> >
> > Differential Revision: https://reviews.llvm.org/D36761
> >
> >
> > Modified:
> > clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
> > clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
> > clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
> > clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.h
> > clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
> > clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.h
> > clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp
> > clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.h
> > clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
> > clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.h
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/android/CloexecCheck.cpp?rev=311020&
> r1=311019=311020=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
> (original)
> > +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp Wed Aug
> 16 09:59:26 2017
> > @@ -20,10 +20,6 @@ namespace tidy {
> >  namespace android {
> >
> >  namespace {
> > -
> > -const char *const FuncDeclBindingStr = "funcDecl";
> > -const char *const FuncBindingStr = "func";
> > -
> >  // Helper function to form the correct string mode for Type3.
> >  // Build the replace text. If it's string constant, add  directly
> in the
> >  // end of the string. Else, add .
> > @@ -41,6 +37,10 @@ std::string buildFixMsgForStringFlag(con
> >  }
> >  } // namespace
> >
> > +constexpr char CloexecCheck::FuncDeclBindingStr[];
> > +
> > +constexpr char CloexecCheck::FuncBindingStr[];
> > +
> >  void CloexecCheck::registerMatchersImpl(
> >  MatchFinder *Finder, internal::Matcher Function) {
> >// We assume all the checked APIs are C functions.
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/android/CloexecCheck.h?rev=311020=
> 311019=311020=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h (original)
> > +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h Wed Aug
> 16 09:59:26 2017
> > @@ -90,6 +90,12 @@ protected:
> >/// Helper function to get the spelling of a particular argument.
> >StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult
> ,
> > int N) const;
> > +
> > +  /// Binding name of the FuncDecl of a function call.
> > +  static constexpr char FuncDeclBindingStr[] = "funcDecl";
> > +
> > +  /// Binding name of the function call expression.
> > +  static constexpr char FuncBindingStr[] = "func";
> >  };
> >
> >  } // namespace android
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/android/
> CloexecCreatCheck.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/android/CloexecCreatCheck.cpp?rev=
> 311020=311019=311020=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
> (original)
> > +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
> Wed Aug 16 09:59:26 2017
> > @@ -10,7 +10,6 @@
> >  #include "CloexecCreatCheck.h"
> >  #include "clang/AST/ASTContext.h"
> >  #include "clang/ASTMatchers/ASTMatchFinder.h"
> > -#include "clang/Lex/Lexer.h"
> >
> >  using namespace clang::ast_matchers;
> >
> > @@ -21,37 +20,22 @@ namespace android {
> >  void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
> >auto CharPointerType = hasType(pointerType(pointee(
> isAnyCharacter(;
> >auto MODETType = hasType(namedDecl(hasName("mode_t")));
> > -
> > -  Finder->addMatcher(
> > -  

[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-16 Thread Brian Gesiak via Phabricator via cfe-commits
modocache planned changes to this revision.
modocache added inline comments.



Comment at: lib/Lex/Preprocessor.cpp:746
 void Preprocessor::Lex(Token ) {
+  llvm::TimeRegion(PPOpts->getTimer());
+

erik.pilkington wrote:
> Doesn't this just start a timer and immediately end the timer? Shouldn't we 
> do: `llvm::TimeRegion LexTime(PPOpts->getTimer())` so that the dtor gets 
> called when this function returns and we track the time spent in this 
> function?
> 
> Also: this is a pretty hot function, and it looks like TimeRegion does some 
> non-trivial work if time is being tracked. Have you tried testing this on a 
> big c++ file with and without this patch and seeing what the difference in 
> compile time looks like?
Ah, yes you're right! Sorry about that. Actually keeping the timer alive for 
the duration of the method also reveals that the method is called recursively, 
which causes an assert, because timers can't be started twice.

Another spot in Clang works around this with a "reference counted" timer: 
https://github.com/llvm-mirror/clang/blob/6ac9c51ede0a50cca13dd4ac03562c036f7a3f48/lib/CodeGen/CodeGenAction.cpp#L130-L134.
 I have a more generic version of this "reference counting timer" that I've 
been using for some of the other timers I've been adding; maybe I'll use it 
here as well.


https://reviews.llvm.org/D36492



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


[clang-tools-extra] r311040 - [clang-tidy] Remove unused static variable.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 14:00:06 2017
New Revision: 311040

URL: http://llvm.org/viewvc/llvm-project?rev=311040=rev
Log:
[clang-tidy] Remove unused static variable.

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


Modified:
clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp?rev=311040=311039=311040=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp Wed Aug 
16 14:00:06 2017
@@ -17,8 +17,6 @@ namespace clang {
 namespace tidy {
 namespace android {
 
-static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
-
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
   registerMatchersImpl(Finder,
functionDecl(isExternC(), returns(isInteger()),


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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-16 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

This looks really usefull, thanks for working on this!




Comment at: lib/Lex/Preprocessor.cpp:746
 void Preprocessor::Lex(Token ) {
+  llvm::TimeRegion(PPOpts->getTimer());
+

Doesn't this just start a timer and immediately end the timer? Shouldn't we do: 
`llvm::TimeRegion LexTime(PPOpts->getTimer())` so that the dtor gets called 
when this function returns and we track the time spent in this function?

Also: this is a pretty hot function, and it looks like TimeRegion does some 
non-trivial work if time is being tracked. Have you tried testing this on a big 
c++ file with and without this patch and seeing what the difference in compile 
time looks like?


https://reviews.llvm.org/D36492



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


Re: [clang-tools-extra] r311020 - [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Evgenii Stepanov via cfe-commits
Hi,

this change breaks build:
clang-tools-extra/clang-tidy/android/CloexecSocketCheck.cpp:20:30:
error: unused variable 'SOCK_CLOEXEC'
[-Werror,-Wunused-const-variable]
static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";

Please test with LLVM_ENABLE_WERROR=ON before submitting!


On Wed, Aug 16, 2017 at 9:59 AM, Chih-Hung Hsieh via cfe-commits
 wrote:
> Author: chh
> Date: Wed Aug 16 09:59:26 2017
> New Revision: 311020
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311020=rev
> Log:
> [clang-tidy] Use CloexecCheck as base class.
>
> Summary:
> Simplify registerMatchers and check functions in CloexecCreatCheck,
> CloexecSocketCheck, CloexecFopenCheck, and CloexecOpenCheck.
>
> Differential Revision: https://reviews.llvm.org/D36761
>
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
> clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
> clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
> clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.h
> clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
> clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.h
> clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp
> clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.h
> clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
> clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.h
>
> Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp?rev=311020=311019=311020=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp Wed Aug 16 
> 09:59:26 2017
> @@ -20,10 +20,6 @@ namespace tidy {
>  namespace android {
>
>  namespace {
> -
> -const char *const FuncDeclBindingStr = "funcDecl";
> -const char *const FuncBindingStr = "func";
> -
>  // Helper function to form the correct string mode for Type3.
>  // Build the replace text. If it's string constant, add  directly in 
> the
>  // end of the string. Else, add .
> @@ -41,6 +37,10 @@ std::string buildFixMsgForStringFlag(con
>  }
>  } // namespace
>
> +constexpr char CloexecCheck::FuncDeclBindingStr[];
> +
> +constexpr char CloexecCheck::FuncBindingStr[];
> +
>  void CloexecCheck::registerMatchersImpl(
>  MatchFinder *Finder, internal::Matcher Function) {
>// We assume all the checked APIs are C functions.
>
> Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h?rev=311020=311019=311020=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h (original)
> +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h Wed Aug 16 
> 09:59:26 2017
> @@ -90,6 +90,12 @@ protected:
>/// Helper function to get the spelling of a particular argument.
>StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
> ,
> int N) const;
> +
> +  /// Binding name of the FuncDecl of a function call.
> +  static constexpr char FuncDeclBindingStr[] = "funcDecl";
> +
> +  /// Binding name of the function call expression.
> +  static constexpr char FuncBindingStr[] = "func";
>  };
>
>  } // namespace android
>
> Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp?rev=311020=311019=311020=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp Wed Aug 
> 16 09:59:26 2017
> @@ -10,7 +10,6 @@
>  #include "CloexecCreatCheck.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/ASTMatchers/ASTMatchFinder.h"
> -#include "clang/Lex/Lexer.h"
>
>  using namespace clang::ast_matchers;
>
> @@ -21,37 +20,22 @@ namespace android {
>  void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
>auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
>auto MODETType = hasType(namedDecl(hasName("mode_t")));
> -
> -  Finder->addMatcher(
> -  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
> -   hasName("creat"),
> -   hasParameter(0, CharPointerType),
> -   hasParameter(1, MODETType))
> -  .bind("funcDecl")))
> -  .bind("creatFn"),
> -  this);
> +  registerMatchersImpl(Finder,

[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.

2017-08-16 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

https://reviews.llvm.org/D36806 switches this to cantFail(). Thanks for helping 
me better understand LLVM's error strategy.


Repository:
  rL LLVM

https://reviews.llvm.org/D36728



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-16 Thread Stephen Hines via Phabricator via cfe-commits
srhines created this revision.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D36806

Files:
  lib/Tooling/Core/Replacement.cpp


Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -498,12 +498,10 @@
 return MergedRanges;
   tooling::Replacements FakeReplaces;
   for (const auto  : MergedRanges) {
-auto Err = FakeReplaces.add(Replacement(Replaces.begin()->getFilePath(),
-R.getOffset(), R.getLength(),
-std::string(R.getLength(), ' ')));
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));
+// Replacements must not conflict since ranges have been merged.
+llvm::cantFail(FakeReplaces.add(
+Replacement(Replaces.begin()->getFilePath(), R.getOffset(),
+R.getLength(), std::string(R.getLength(), ' ';
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }


Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -498,12 +498,10 @@
 return MergedRanges;
   tooling::Replacements FakeReplaces;
   for (const auto  : MergedRanges) {
-auto Err = FakeReplaces.add(Replacement(Replaces.begin()->getFilePath(),
-R.getOffset(), R.getLength(),
-std::string(R.getLength(), ' ')));
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));
+// Replacements must not conflict since ranges have been merged.
+llvm::cantFail(FakeReplaces.add(
+Replacement(Replaces.begin()->getFilePath(), R.getOffset(),
+R.getLength(), std::string(R.getLength(), ' ';
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-16 Thread Taewook Oh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311037: Use the file name from linemarker for debug info if 
an input is preprocessed… (authored by twoh).

Repository:
  rL LLVM

https://reviews.llvm.org/D36474

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -495,6 +496,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 
Index: cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
===
--- cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
+++ cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,11 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c"


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -495,6 +496,16 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 
Index: cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
===
--- cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
+++ cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
@@ -0,0 +1,11 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311037 - Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-16 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Wed Aug 16 12:36:24 2017
New Revision: 311037

URL: http://llvm.org/viewvc/llvm-project?rev=311037=rev
Log:
Use the file name from linemarker for debug info if an input is preprocessed 
source.

Summary:
Even in the case of the input file is a preprocessed source, clang uses the 
file name of the preprocesses source for debug info (DW_AT_name attribute for 
DW_TAG_compile_unit). However, gcc uses the file name specified in the first 
linemarker instead. This makes more sense because the one specified in the 
linemarker represents the "actual" source file name.

Clang already uses the file name specified in the first linemarker for Module 
name 
(https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendAction.cpp#L779)
 if the input is preprocessed. This patch makes clang to use the same value for 
debug info as well.

Reviewers: compnerd, rnk, dblaikie, rsmith

Reviewed By: rnk

Subscribers: aprantl, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311037=311036=311037=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 16 12:36:24 2017
@@ -29,6 +29,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -495,6 +496,16 @@ void CGDebugInfo::CreateCompileUnit() {
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+// If the main file name provided is identical to the input file name, and
+// if the input file is a preprocessed source, use the module name for
+// debug info. The module name comes from the name specified in the first
+// linemarker if the input is a preprocessed source.
+if (MainFile->getName() == MainFileName &&
+FrontendOptions::getInputKindForExtension(
+MainFile->getName().rsplit('.').second)
+.isPreprocessed())
+  MainFileName = CGM.getModule().getName().str();
+
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 

Added: cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i?rev=311037=auto
==
--- cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i (added)
+++ cfe/trunk/test/CodeGen/debug-info-preprocessed-file.i Wed Aug 16 12:36:24 
2017
@@ -0,0 +1,11 @@
+# 1 "/foo/bar/preprocessed-input.c"
+# 1 "" 1
+# 1 "" 3
+# 318 "" 3
+# 1 "" 1
+# 1 "" 2
+# 1 "preprocessed-input.c" 2
+
+// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s
+// CHECK: !DICompileUnit(language: DW_LANG_C99, file: ![[FILE:[0-9]+]] 
+// CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c"


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


[clang-tools-extra] r311035 - [clang-tidy] Use const char* to compile with VC cl.exe.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 12:13:35 2017
New Revision: 311035

URL: http://llvm.org/viewvc/llvm-project?rev=311035=rev
Log:
[clang-tidy] Use const char* to compile with VC cl.exe.

Summary:
cl.exe does not accept constexpr char FuncBindingStr[] = ...

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


Modified:
clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp?rev=311035=311034=311035=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp Wed Aug 16 
12:13:35 2017
@@ -37,9 +37,9 @@ std::string buildFixMsgForStringFlag(con
 }
 } // namespace
 
-constexpr char CloexecCheck::FuncDeclBindingStr[];
+const char *CloexecCheck::FuncDeclBindingStr = "funcDecl";
 
-constexpr char CloexecCheck::FuncBindingStr[];
+const char *CloexecCheck::FuncBindingStr ="func";
 
 void CloexecCheck::registerMatchersImpl(
 MatchFinder *Finder, internal::Matcher Function) {

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h?rev=311035=311034=311035=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h Wed Aug 16 
12:13:35 2017
@@ -92,10 +92,10 @@ protected:
int N) const;
 
   /// Binding name of the FuncDecl of a function call.
-  static constexpr char FuncDeclBindingStr[] = "funcDecl";
+  static const char *FuncDeclBindingStr;
 
   /// Binding name of the function call expression.
-  static constexpr char FuncBindingStr[] = "func";
+  static const char *FuncBindingStr;
 };
 
 } // namespace android


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


[PATCH] D36779: [Driver] SafeStack does not need a runtime library on Fuchsia

2017-08-16 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311034: [Driver] SafeStack does not need a runtime library 
on Fuchsia (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D36779?vs=111301=111400#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36779

Files:
  cfe/trunk/include/clang/Driver/SanitizerArgs.h
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/test/Driver/fuchsia.c


Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp
===
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp
@@ -605,6 +605,11 @@
 AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+// SafeStack runtime is built into the system on Fuchsia.
+SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
   Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
Index: cfe/trunk/include/clang/Driver/SanitizerArgs.h
===
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h
@@ -38,6 +38,7 @@
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -45,6 +45,8 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=address 2>&1 \


Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp
===
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp
@@ -605,6 +605,11 @@
 AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+// SafeStack runtime is built into the system on Fuchsia.
+SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
   Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
Index: cfe/trunk/include/clang/Driver/SanitizerArgs.h
===
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h
@@ -38,6 +38,7 @@
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -45,6 +45,8 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36349: [CMake] Build sanitized C++ runtimes for Fuchsia

2017-08-16 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311033: [CMake] Build sanitized C++ runtimes for Fuchsia 
(authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D36349?vs=110311=111399#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36349

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -33,24 +33,30 @@
 endforeach()
 
 if(NOT APPLE)
-  list(APPEND LLVM_BUILTIN_TARGETS "default")
+  set(LLVM_BUILTIN_TARGETS "default;${LLVM_BUILTIN_TARGETS}" CACHE STRING "" 
FORCE)
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
+
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX 
"${target}-fuchsia/" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_LIBDIR_SUFFIX "/asan" 
CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -33,24 +33,30 @@
 endforeach()
 
 if(NOT APPLE)
-  list(APPEND LLVM_BUILTIN_TARGETS "default")
+  set(LLVM_BUILTIN_TARGETS "default;${LLVM_BUILTIN_TARGETS}" CACHE STRING "" FORCE)
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
+
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX "${target}-fuchsia/" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_LIBDIR_SUFFIX "/asan" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311034 - [Driver] SafeStack does not need a runtime library on Fuchsia

2017-08-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug 16 12:06:05 2017
New Revision: 311034

URL: http://llvm.org/viewvc/llvm-project?rev=311034=rev
Log:
[Driver] SafeStack does not need a runtime library on Fuchsia

Patch by Roland McGrath

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

Modified:
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=311034=311033=311034=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Wed Aug 16 12:06:05 2017
@@ -38,6 +38,7 @@ class SanitizerArgs {
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@ class SanitizerArgs {
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=311034=311033=311034=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed Aug 16 12:06:05 2017
@@ -605,6 +605,11 @@ SanitizerArgs::SanitizerArgs(const ToolC
 AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+// SafeStack runtime is built into the system on Fuchsia.
+SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
   Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=311034=311033=311034=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Wed Aug 16 12:06:05 2017
@@ -45,6 +45,8 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=address 2>&1 \


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


r311033 - [CMake] Build sanitized C++ runtimes for Fuchsia

2017-08-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug 16 12:06:04 2017
New Revision: 311033

URL: http://llvm.org/viewvc/llvm-project?rev=311033=rev
Log:
[CMake] Build sanitized C++ runtimes for Fuchsia

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=311033=311032=311033=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Wed Aug 16 12:06:04 2017
@@ -33,10 +33,10 @@ foreach(target x86_64;aarch64)
 endforeach()
 
 if(NOT APPLE)
-  list(APPEND LLVM_BUILTIN_TARGETS "default")
+  set(LLVM_BUILTIN_TARGETS "default;${LLVM_BUILTIN_TARGETS}" CACHE STRING "" 
FORCE)
 endif()
 
-set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
@@ -44,6 +44,7 @@ foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
@@ -51,6 +52,11 @@ foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
+
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_PREFIX 
"${target}-fuchsia/" CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LLVM_RUNTIMES_LIBDIR_SUFFIX "/asan" 
CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia-asan_LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
 endforeach()
 
 # Setup toolchain.


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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In https://reviews.llvm.org/D36712#843414, @kparzysz wrote:

> The problem is that the mismatch between sections does not have to lead to 
> any undesirable behavior.  Whether it does or not depends on a particular 
> case.  I think we should be consistent though---if we decide that a mismatch 
> between the section for a declaration and the section for a definition leads 
> to an undefined behavior, then it should be so regardless of whether the 
> sections were given explicitly or inferred.


Ok. That makes sense. I've updated the documentation to reflect this. Please 
let me know if it needs to be more detailed.


https://reviews.llvm.org/D36712



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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D36492



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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-16 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Friendly ping! I think this is ready to be reviewed. It adds an additional row, 
`Preprocessing`, to the `Miscellaneous Ungrouped Timers` section of the `clang 
-ftime-report` output:

  
===-===
   Miscellaneous Ungrouped Timers
  
===-===
  
 ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- 
Name ---
 0.0360 ( 17.8%)   0.0060 ( 35.3%)   0.0420 ( 19.2%)   0.3440 ( 50.6%)  
Code Generation Time
 0.0390 ( 19.3%)   0.0050 ( 29.4%)   0.0440 ( 20.1%)   0.1734 ( 25.5%)  
LLVM IR Generation Time
 0.1270 ( 62.9%)   0.0060 ( 35.3%)   0.1330 ( 60.7%)   0.1622 ( 23.9%)  
Preprocessing
 0.2020 (100.0%)   0.0170 (100.0%)   0.2190 (100.0%)   0.6796 (100.0%)  
Total

Grouping these timers is something I'd like to explore in future commits.


https://reviews.llvm.org/D36492



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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 111388.
eandrews added a comment.

Updated the patch to include Krzysztof's comment about explicitly stating 
undefined behavior for section information mismatch in global variable 
declaration and definition. This should cover the case where section is 
explicitly specified in definition but not declaration.


https://reviews.llvm.org/D36712

Files:
  docs/LangRef.rst


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -579,7 +579,9 @@
 case they don't have an initializer.
 
 Either global variable definitions or declarations may have an explicit section
-to be placed in and may have an optional explicit alignment specified.
+to be placed in and may have an optional explicit alignment specified. A 
+mismatch between section information in the variable declaration and its
+definition is undefined behavior. 
 
 A variable may be defined as a global ``constant``, which indicates that
 the contents of the variable will **never** be modified (enabling better
@@ -622,6 +624,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that its definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -579,7 +579,9 @@
 case they don't have an initializer.
 
 Either global variable definitions or declarations may have an explicit section
-to be placed in and may have an optional explicit alignment specified.
+to be placed in and may have an optional explicit alignment specified. A 
+mismatch between section information in the variable declaration and its
+definition is undefined behavior. 
 
 A variable may be defined as a global ``constant``, which indicates that
 the contents of the variable will **never** be modified (enabling better
@@ -622,6 +624,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that its definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36802: AMDGPU: Insert __devicename__ macros

2017-08-16 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Do we need this for r600?


https://reviews.llvm.org/D36802



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


[PATCH] D36802: AMDGPU: Insert __devicename__ macros

2017-08-16 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D36802

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  test/Driver/amdgcn-mcpu-macro.cl
  test/Driver/r600-mcpu-macro.cl
  test/Driver/r600-mcpu.cl

Index: test/Driver/r600-mcpu.cl
===
--- test/Driver/r600-mcpu.cl
+++ test/Driver/r600-mcpu.cl
@@ -1,4 +1,4 @@
-t// Check that -mcpu works for all supported GPUs
+// Check that -mcpu works for all supported GPUs
 
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=r600 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv630 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
@@ -26,22 +26,6 @@
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 | FileCheck --check-prefix=CAICOS-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kabini %s -o - 2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=mullins %s -o - 2>&1 | FileCheck --check-prefix=MULLINS-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -58,19 +42,71 @@
 // TURKS-CHECK: "-target-cpu" "turks"
 // CAICOS-CHECK: "-target-cpu" "caicos"
 // CAYMAN-CHECK: "-target-cpu" "cayman"
+
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx600 %s -o - 2>&1 | FileCheck --check-prefix=GFX600-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx601 %s -o - 2>&1 | FileCheck --check-prefix=GFX601-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hainan %s -o - 2>&1 | FileCheck --check-prefix=HAINAN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx700 %s -o - 2>&1 | FileCheck --check-prefix=GFX700-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx701 %s -o - 2>&1 | FileCheck --check-prefix=GFX701-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm 

[PATCH] D36771: AMDGPU: add missing amdgcn processors and tests

2017-08-16 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

In https://reviews.llvm.org/D36771#842837, @arsenm wrote:

> We should also be defining __devicename__ macros. I opened a bug for this 
> last week


https://reviews.llvm.org/D36802


https://reviews.llvm.org/D36771



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


[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: doug.gregor.
rjmccall added a comment.

Tagging Doug.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added inline comments.



Comment at: clang-tidy/android/CloexecEpollCreateCheck.cpp:27-31
+  replaceFunc(Result, /*WarningMsg=*/
+  "prefer epoll_create() to epoll_create1() "
+  "because epoll_create1() allows "
+  "EPOLL_CLOEXEC", /*FixMsg=*/
+  "epoll_create1(EPOLL_CLOEXEC)");

alexfh wrote:
> nit: Please remove argument comments, they don't add any useful information.
Done.



Repository:
  rL LLVM

https://reviews.llvm.org/D35367



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311029: [clang-tidy] Add a close-on-exec check on 
epoll_create() in Android module. (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D35367?vs=110751=111386#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35367

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-epoll-create.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-epoll-create.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
@@ -7,6 +7,7 @@
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
   CloexecEpollCreate1Check.cpp
+  CloexecEpollCreateCheck.cpp
   CloexecDupCheck.cpp
   CloexecFopenCheck.cpp
   CloexecInotifyInit1Check.cpp
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -14,6 +14,7 @@
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecEpollCreate1Check.h"
+#include "CloexecEpollCreateCheck.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
 #include "CloexecInotifyInit1Check.h"
@@ -37,6 +38,8 @@
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck(
 "android-cloexec-epoll-create1");
+CheckFactories.registerCheck(
+"android-cloexec-epoll-create");
 CheckFactories.registerCheck("android-cloexec-dup");
 CheckFactories.registerCheck("android-cloexec-fopen");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreateCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// epoll_create() is better to be replaced by epoll_create1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll-create.html
+class CloexecEpollCreateCheck : public CloexecCheck {
+public:
+  CloexecEpollCreateCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
@@ -0,0 +1,36 @@
+//===--- CloexecEpollCreateCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreateCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreateCheck::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(
+  Finder, functionDecl(returns(isInteger()), hasName("epoll_create"),
+   hasParameter(0, hasType(isInteger();
+}
+
+void 

[clang-tools-extra] r311029 - [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 11:02:49 2017
New Revision: 311029

URL: http://llvm.org/viewvc/llvm-project?rev=311029=rev
Log:
[clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

Summary:
epoll_create() is better to be replaced by epoll_create1() with EPOLL_CLOEXEC
flag to avoid file descriptor leakage.

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


Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-epoll-create.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-epoll-create.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=311029=311028=311029=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Aug 16 
11:02:49 2017
@@ -14,6 +14,7 @@
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecEpollCreate1Check.h"
+#include "CloexecEpollCreateCheck.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
 #include "CloexecInotifyInit1Check.h"
@@ -37,6 +38,8 @@ public:
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck(
 "android-cloexec-epoll-create1");
+CheckFactories.registerCheck(
+"android-cloexec-epoll-create");
 CheckFactories.registerCheck("android-cloexec-dup");
 CheckFactories.registerCheck("android-cloexec-fopen");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=311029=311028=311029=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Aug 16 
11:02:49 2017
@@ -7,6 +7,7 @@ add_clang_library(clangTidyAndroidModule
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
   CloexecEpollCreate1Check.cpp
+  CloexecEpollCreateCheck.cpp
   CloexecDupCheck.cpp
   CloexecFopenCheck.cpp
   CloexecInotifyInit1Check.cpp

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp?rev=311029=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.cpp Wed 
Aug 16 11:02:49 2017
@@ -0,0 +1,36 @@
+//===--- CloexecEpollCreateCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreateCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreateCheck::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(
+  Finder, functionDecl(returns(isInteger()), hasName("epoll_create"),
+   hasParameter(0, hasType(isInteger();
+}
+
+void CloexecEpollCreateCheck::check(const MatchFinder::MatchResult ) {
+  replaceFunc(Result,
+  "prefer epoll_create() to epoll_create1() "
+  "because epoll_create1() allows "
+  "EPOLL_CLOEXEC",
+  "epoll_create1(EPOLL_CLOEXEC)");
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h?rev=311029=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreateCheck.h Wed 
Aug 16 11:02:49 2017
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreateCheck.h - clang-tidy--*- C++ 
-*-===//
+//
+// 

[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311028: [clang-tidy] Add a close-on-exec check on 
epoll_create1() in Android module. (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D35365?vs=110752=111385#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35365

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-epoll-create1.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
@@ -6,6 +6,7 @@
   CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
+  CloexecEpollCreate1Check.cpp
   CloexecDupCheck.cpp
   CloexecFopenCheck.cpp
   CloexecInotifyInit1Check.cpp
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreate1Check.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that uses epoll_create1() without using the EPOLL_CLOEXEC flag.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll-create1.html
+class CloexecEpollCreate1Check : public CloexecCheck {
+public:
+  CloexecEpollCreate1Check(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
@@ -0,0 +1,33 @@
+//===--- CloexecEpollCreate1Check.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreate1Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreate1Check::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(
+  Finder, functionDecl(returns(isInteger()), hasName("epoll_create1"),
+   hasParameter(0, hasType(isInteger();
+}
+
+void CloexecEpollCreate1Check::check(const MatchFinder::MatchResult ) {
+  insertMacroFlag(Result, /*MarcoFlag=*/"EPOLL_CLOEXEC", /*ArgPos=*/0);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "CloexecAccept4Check.h"
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
+#include "CloexecEpollCreate1Check.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
 #include "CloexecInotifyInit1Check.h"
@@ -34,6 +35,8 @@
 CheckFactories.registerCheck("android-cloexec-accept4");
 CheckFactories.registerCheck("android-cloexec-accept");
 

[clang-tools-extra] r311028 - [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 10:53:12 2017
New Revision: 311028

URL: http://llvm.org/viewvc/llvm-project?rev=311028=rev
Log:
[clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

Summary:
epoll_create1() is better to set EPOLL_CLOEXEC flag to avoid file descriptor 
leakage.

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


Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h

clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-epoll-create1.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=311028=311027=311028=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Aug 16 
10:53:12 2017
@@ -13,6 +13,7 @@
 #include "CloexecAccept4Check.h"
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
+#include "CloexecEpollCreate1Check.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
 #include "CloexecInotifyInit1Check.h"
@@ -34,6 +35,8 @@ public:
 
CheckFactories.registerCheck("android-cloexec-accept4");
 CheckFactories.registerCheck("android-cloexec-accept");
 CheckFactories.registerCheck("android-cloexec-creat");
+CheckFactories.registerCheck(
+"android-cloexec-epoll-create1");
 CheckFactories.registerCheck("android-cloexec-dup");
 CheckFactories.registerCheck("android-cloexec-fopen");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=311028=311027=311028=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Aug 16 
10:53:12 2017
@@ -6,6 +6,7 @@ add_clang_library(clangTidyAndroidModule
   CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
+  CloexecEpollCreate1Check.cpp
   CloexecDupCheck.cpp
   CloexecFopenCheck.cpp
   CloexecInotifyInit1Check.cpp

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp?rev=311028=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.cpp Wed 
Aug 16 10:53:12 2017
@@ -0,0 +1,33 @@
+//===--- CloexecEpollCreate1Check.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreate1Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreate1Check::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(
+  Finder, functionDecl(returns(isInteger()), hasName("epoll_create1"),
+   hasParameter(0, hasType(isInteger();
+}
+
+void CloexecEpollCreate1Check::check(const MatchFinder::MatchResult ) {
+  insertMacroFlag(Result, /*MarcoFlag=*/"EPOLL_CLOEXEC", /*ArgPos=*/0);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h?rev=311028=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h 
(added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecEpollCreate1Check.h Wed 
Aug 16 10:53:12 2017
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreate1Check.h - clang-tidy-*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is 

[PATCH] D35363: [clang-tidy] Add a close-on-exec check on accept4() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311027: [clang-tidy] Add a close-on-exec check on accept4() 
in Android module. (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D35363?vs=110755=111383#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35363

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-accept4.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-accept4.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
+  CloexecAccept4Check.cpp
   CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecAccept4Check.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT4_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT4_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that uses accept4() without using the SOCK_CLOEXEC flag.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept4.html
+class CloexecAccept4Check : public CloexecCheck {
+public:
+  CloexecAccept4Check(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT4_H
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
@@ -0,0 +1,40 @@
+//===--- CloexecAccept4Check.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecAccept4Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecAccept4Check::registerMatchers(MatchFinder *Finder) {
+  auto SockAddrPointerType =
+  hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr";
+  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t";
+
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("accept4"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, SockAddrPointerType),
+hasParameter(2, SockLenPointerType),
+hasParameter(3, hasType(isInteger();
+}
+
+void CloexecAccept4Check::check(const MatchFinder::MatchResult ) {
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/3);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include 

[clang-tools-extra] r311027 - [clang-tidy] Add a close-on-exec check on accept4() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 10:46:18 2017
New Revision: 311027

URL: http://llvm.org/viewvc/llvm-project?rev=311027=rev
Log:
[clang-tidy] Add a close-on-exec check on accept4() in Android module.

Summary:
accept4() is better to set SOCK_CLOEXEC flag to avoid file descriptor leakage.

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


Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-accept4.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-accept4.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=311027=311026=311027=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Aug 16 
10:46:18 2017
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CloexecAccept4Check.h"
 #include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecDupCheck.h"
@@ -30,6 +31,7 @@ namespace android {
 class AndroidModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+
CheckFactories.registerCheck("android-cloexec-accept4");
 CheckFactories.registerCheck("android-cloexec-accept");
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck("android-cloexec-dup");

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=311027=311026=311027=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Aug 16 
10:46:18 2017
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
+  CloexecAccept4Check.cpp
   CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp?rev=311027=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.cpp Wed Aug 
16 10:46:18 2017
@@ -0,0 +1,40 @@
+//===--- CloexecAccept4Check.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecAccept4Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecAccept4Check::registerMatchers(MatchFinder *Finder) {
+  auto SockAddrPointerType =
+  hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr";
+  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t";
+
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("accept4"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, SockAddrPointerType),
+hasParameter(2, SockLenPointerType),
+hasParameter(3, hasType(isInteger();
+}
+
+void CloexecAccept4Check::check(const MatchFinder::MatchResult ) {
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/3);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h?rev=311027=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAccept4Check.h (added)
+++ 

[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D36474



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


[PATCH] D34796: upporting -f(no)-reorder-functions flag, clang side change

2017-08-16 Thread Taewook Oh via Phabricator via cfe-commits
twoh added a comment.

Friendly ping. @davidxl, I think there's no harm to make clang consistent with 
gcc for compiler options, and I wonder if you have any concerns that I may 
miss. Thanks!


https://reviews.llvm.org/D34796



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


[PATCH] D36474: Use the file name from linemarker for debug info if an input is preprocessed source.

2017-08-16 Thread Taewook Oh via Phabricator via cfe-commits
twoh added a comment.

Ping. Thanks!


https://reviews.llvm.org/D36474



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


[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311024: [clang-tidy] Add a close-on-exec check on accept() 
in Android module. (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D35362?vs=111377=111378#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35362

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-accept.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-accept.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
+  CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
   CloexecDupCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
@@ -29,6 +30,7 @@
 class AndroidModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("android-cloexec-accept");
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck("android-cloexec-dup");
 CheckFactories.registerCheck("android-cloexec-fopen");
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecAcceptCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecAcceptCheck : public CloexecCheck {
+public:
+  CloexecAcceptCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
@@ -0,0 +1,47 @@
+//===--- CloexecAcceptCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecAcceptCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) {
+  auto SockAddrPointerType =
+  hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr";
+  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t";
+
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("accept"),
+hasParameter(0, hasType(isInteger())),
+ 

[clang-tools-extra] r311024 - [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 10:18:16 2017
New Revision: 311024

URL: http://llvm.org/viewvc/llvm-project?rev=311024=rev
Log:
[clang-tidy] Add a close-on-exec check on accept() in Android module.

Summary:
accept() is better to be replaced by accept4() with SOCK_CLOEXEC
flag to avoid file descriptor leakage.

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


Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-accept.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-accept.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=311024=311023=311024=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Aug 16 
10:18:16 2017
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CloexecAcceptCheck.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecDupCheck.h"
 #include "CloexecFopenCheck.h"
@@ -29,6 +30,7 @@ namespace android {
 class AndroidModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck("android-cloexec-accept");
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck("android-cloexec-dup");
 CheckFactories.registerCheck("android-cloexec-fopen");

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=311024=311023=311024=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Aug 16 
10:18:16 2017
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
+  CloexecAcceptCheck.cpp
   CloexecCheck.cpp
   CloexecCreatCheck.cpp
   CloexecDupCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp?rev=311024=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.cpp Wed Aug 
16 10:18:16 2017
@@ -0,0 +1,47 @@
+//===--- CloexecAcceptCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecAcceptCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) {
+  auto SockAddrPointerType =
+  hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr";
+  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t";
+
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("accept"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, SockAddrPointerType),
+hasParameter(2, SockLenPointerType)));
+}
+
+void CloexecAcceptCheck::check(const MatchFinder::MatchResult ) {
+  const std::string  =
+  (Twine("accept4(") + getSpellingArg(Result, 0) + ", " +
+   getSpellingArg(Result, 1) + ", " + getSpellingArg(Result, 2) +
+   ", SOCK_CLOEXEC)")
+  .str();
+
+  replaceFunc(
+  Result,
+  "prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC",
+  ReplacementText);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecAcceptCheck.h?rev=311024=auto

[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 111377.

https://reviews.llvm.org/D35362

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecAcceptCheck.cpp
  clang-tidy/android/CloexecAcceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-accept.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-accept.cpp

Index: test/clang-tidy/android-cloexec-accept.cpp
===
--- test/clang-tidy/android-cloexec-accept.cpp
+++ test/clang-tidy/android-cloexec-accept.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s android-cloexec-accept %t
+
+struct sockaddr {};
+typedef int socklen_t;
+#define NULL 0
+
+extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
+void f() {
+  accept(0, NULL, NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept]
+  // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC);
+}
+
+namespace i {
+int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+void g() {
+  accept(0, NULL, NULL);
+}
+} // namespace i
+
+class C {
+public:
+  int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+  void h() {
+accept(0, NULL, NULL);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   android-cloexec-accept
android-cloexec-creat
android-cloexec-dup
android-cloexec-fopen
Index: docs/clang-tidy/checks/android-cloexec-accept.rst
===
--- docs/clang-tidy/checks/android-cloexec-accept.rst
+++ docs/clang-tidy/checks/android-cloexec-accept.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-accept
+
+android-cloexec-accept
+==
+
+The usage of ``accept()`` is not recommended, it's better to use ``accept4()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  accept(sockfd, addr, addrlen);
+
+  // becomes
+
+  accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,11 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-accept
+  `_ check
+
+  Detects usage of ``accept()``.
+
 - New `android-cloexec-dup
   `_ check
 
Index: clang-tidy/android/CloexecAcceptCheck.h
===
--- clang-tidy/android/CloexecAcceptCheck.h
+++ clang-tidy/android/CloexecAcceptCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecAcceptCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecAcceptCheck : public CloexecCheck {
+public:
+  CloexecAcceptCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
Index: clang-tidy/android/CloexecAcceptCheck.cpp
===
--- clang-tidy/android/CloexecAcceptCheck.cpp
+++ clang-tidy/android/CloexecAcceptCheck.cpp
@@ -0,0 +1,47 @@
+//===--- CloexecAcceptCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 

[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh commandeered this revision.
chh added a reviewer: yawanng.
chh added inline comments.



Comment at: clang-tidy/android/CloexecAcceptCheck.cpp:42
+  "prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC",
+  /*FixMsg=*/ReplacementText);
+}

alexfh wrote:
> Two minor issues here:
> 1. `FixMsg` name is misleading, specifically the "Msg" part, since it's not a 
> message.
> 2. there's no need to use an argument comment, where it's clear what the 
> actual argument's meaning is. E.g. `ReplacementText` is pretty clear on its 
> own. As is the warning message above.
Done.


https://reviews.llvm.org/D35362



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


[libclc] r311022 - amdgcn: rewrite barrier() using fence and clang __builtin_amdgcn_s_barrier

2017-08-16 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Aug 16 10:09:00 2017
New Revision: 311022

URL: http://llvm.org/viewvc/llvm-project?rev=311022=rev
Log:
amdgcn: rewrite barrier() using fence and clang __builtin_amdgcn_s_barrier

Specs require using fences when barrier() is invoked:
"The barrier function will either flush any variables stored in local memory
or queue a memory fence to ensure correct ordering of memory operations to 
local memory."
and
"The barrier function will queue a memory fence to ensure correct ordering
of memory operations to global memory."

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/amdgcn/lib/synchronization/barrier.cl
Removed:
libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll
Modified:
libclc/trunk/amdgcn/lib/SOURCES

Modified: libclc/trunk/amdgcn/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=311022=311021=311022=diff
==
--- libclc/trunk/amdgcn/lib/SOURCES (original)
+++ libclc/trunk/amdgcn/lib/SOURCES Wed Aug 16 10:09:00 2017
@@ -1,7 +1,7 @@
 math/ldexp.cl
 mem_fence/fence.cl
 mem_fence/waitcnt.ll
-synchronization/barrier_impl.ll
+synchronization/barrier.cl
 workitem/get_global_offset.cl
 workitem/get_group_id.cl
 workitem/get_global_size.ll

Added: libclc/trunk/amdgcn/lib/synchronization/barrier.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/synchronization/barrier.cl?rev=311022=auto
==
--- libclc/trunk/amdgcn/lib/synchronization/barrier.cl (added)
+++ libclc/trunk/amdgcn/lib/synchronization/barrier.cl Wed Aug 16 10:09:00 2017
@@ -0,0 +1,7 @@
+#include 
+
+_CLC_DEF void barrier(cl_mem_fence_flags flags)
+{
+   mem_fence(flags);
+   __builtin_amdgcn_s_barrier();
+}

Removed: libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll?rev=311021=auto
==
--- libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll (original)
+++ libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll (removed)
@@ -1,32 +0,0 @@
-declare i32 @__clc_clk_local_mem_fence() #1
-declare i32 @__clc_clk_global_mem_fence() #1
-declare void @llvm.amdgcn.s.barrier() #0
-
-define void @barrier(i32 %flags) #2 {
-barrier_local_test:
-  %CLK_LOCAL_MEM_FENCE = call i32 @__clc_clk_local_mem_fence()
-  %0 = and i32 %flags, %CLK_LOCAL_MEM_FENCE
-  %1 = icmp ne i32 %0, 0
-  br i1 %1, label %barrier_local, label %barrier_global_test
-
-barrier_local:
-  call void @llvm.amdgcn.s.barrier()
-  br label %barrier_global_test
-
-barrier_global_test:
-  %CLK_GLOBAL_MEM_FENCE = call i32 @__clc_clk_global_mem_fence()
-  %2 = and i32 %flags, %CLK_GLOBAL_MEM_FENCE
-  %3 = icmp ne i32 %2, 0
-  br i1 %3, label %barrier_global, label %done
-
-barrier_global:
-  call void @llvm.amdgcn.s.barrier()
-  br label %done
-
-done:
-  ret void
-}
-
-attributes #0 = { nounwind convergent }
-attributes #1 = { nounwind alwaysinline }
-attributes #2 = { nounwind convergent alwaysinline }


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


[libclc] r311021 - amdgcn: Implement {read_, write_, }mem_fence builtin

2017-08-16 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Aug 16 10:08:56 2017
New Revision: 311021

URL: http://llvm.org/viewvc/llvm-project?rev=311021=rev
Log:
amdgcn: Implement {read_,write_,}mem_fence builtin

v2: add more detailed comment about waitcnt instruction

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/amdgcn/lib/mem_fence/
libclc/trunk/amdgcn/lib/mem_fence/fence.cl
libclc/trunk/amdgcn/lib/mem_fence/waitcnt.ll
libclc/trunk/generic/include/clc/explicit_fence/
libclc/trunk/generic/include/clc/explicit_fence/explicit_memory_fence.h
Modified:
libclc/trunk/amdgcn/lib/SOURCES
libclc/trunk/generic/include/clc/clc.h

Modified: libclc/trunk/amdgcn/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=311021=311020=311021=diff
==
--- libclc/trunk/amdgcn/lib/SOURCES (original)
+++ libclc/trunk/amdgcn/lib/SOURCES Wed Aug 16 10:08:56 2017
@@ -1,4 +1,6 @@
 math/ldexp.cl
+mem_fence/fence.cl
+mem_fence/waitcnt.ll
 synchronization/barrier_impl.ll
 workitem/get_global_offset.cl
 workitem/get_group_id.cl

Added: libclc/trunk/amdgcn/lib/mem_fence/fence.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/mem_fence/fence.cl?rev=311021=auto
==
--- libclc/trunk/amdgcn/lib/mem_fence/fence.cl (added)
+++ libclc/trunk/amdgcn/lib/mem_fence/fence.cl Wed Aug 16 10:08:56 2017
@@ -0,0 +1,39 @@
+#include 
+
+void __clc_amdgcn_s_waitcnt(unsigned flags);
+
+// s_waitcnt takes 16bit argument with a combined number of maximum allowed
+// pending operations:
+// [12:8] LGKM -- LDS, GDS, Konstant (SMRD), Messages
+// [7] -- undefined
+// [6:4] -- exports, GDS, and mem write
+// [3:0] -- vector memory operations
+
+// Newer clang supports __builtin_amdgcn_s_waitcnt
+#if __clang_major__ >= 5
+#  define __waitcnt(x) __builtin_amdgcn_s_waitcnt(x)
+#else
+#  define __waitcnt(x) __clc_amdgcn_s_waitcnt(x)
+#endif
+
+_CLC_DEF void mem_fence(cl_mem_fence_flags flags)
+{
+   if (flags & CLK_GLOBAL_MEM_FENCE) {
+   // scalar loads are counted with LGKM but we don't know whether
+   // the compiler turned any loads to scalar
+   __waitcnt(0);
+   } else if (flags & CLK_LOCAL_MEM_FENCE)
+   __waitcnt(0xff); // LGKM is [12:8]
+}
+#undef __waitcnt
+
+// We don't have separate mechanism for read and write fences
+_CLC_DEF void read_mem_fence(cl_mem_fence_flags flags)
+{
+   mem_fence(flags);
+}
+
+_CLC_DEF void write_mem_fence(cl_mem_fence_flags flags)
+{
+   mem_fence(flags);
+}

Added: libclc/trunk/amdgcn/lib/mem_fence/waitcnt.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/mem_fence/waitcnt.ll?rev=311021=auto
==
--- libclc/trunk/amdgcn/lib/mem_fence/waitcnt.ll (added)
+++ libclc/trunk/amdgcn/lib/mem_fence/waitcnt.ll Wed Aug 16 10:08:56 2017
@@ -0,0 +1,11 @@
+declare void @llvm.amdgcn.s.waitcnt(i32) #0
+
+; Export waitcnt intrinsic for clang < 5
+define void @__clc_amdgcn_s_waitcnt(i32 %flags) #1 {
+entry:
+  tail call void @llvm.amdgcn.s.waitcnt(i32 %flags)
+  ret void
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind alwaysinline }

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=311021=311020=311021=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Aug 16 10:08:56 2017
@@ -179,6 +179,9 @@
 #include 
 #include 
 
+/* 6.11.9 Explicit Memory Fence Functions */
+#include 
+
 /* 6.11.10 Async Copy and Prefetch Functions */
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/explicit_fence/explicit_memory_fence.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/explicit_fence/explicit_memory_fence.h?rev=311021=auto
==
--- libclc/trunk/generic/include/clc/explicit_fence/explicit_memory_fence.h 
(added)
+++ libclc/trunk/generic/include/clc/explicit_fence/explicit_memory_fence.h Wed 
Aug 16 10:08:56 2017
@@ -0,0 +1,3 @@
+_CLC_DECL void mem_fence(cl_mem_fence_flags flags);
+_CLC_DECL void read_mem_fence(cl_mem_fence_flags flags);
+_CLC_DECL void write_mem_fence(cl_mem_fence_flags flags);


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


[PATCH] D36761: [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311020: [clang-tidy] Use CloexecCheck as base class. 
(authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D36761?vs=111372=111373#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36761

Files:
  clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
  clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.h
  clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.h
  clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.h
  clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.h

Index: clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -21,35 +20,16 @@
 static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
 
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("socket"),
-   hasParameter(0, hasType(isInteger())),
-   hasParameter(1, hasType(isInteger())),
-   hasParameter(2, hasType(isInteger(
-  .bind("funcDecl")))
-  .bind("socketFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("socket"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, hasType(isInteger())),
+hasParameter(2, hasType(isInteger();
 }
 
 void CloexecSocketCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("socketFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *FlagArg = MatchedCall->getArg(1);
-  SourceManager  = *Result.SourceManager;
-
-  if (utils::exprHasBitFlagWithSpelling(FlagArg->IgnoreParenCasts(), SM,
- Result.Context->getLangOpts(), SOCK_CLOEXEC))
-return;
-
-  SourceLocation EndLoc =
-  Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
- Result.Context->getLangOpts());
-
-  diag(EndLoc, "%0 should use %1 where possible")
-  << FD << SOCK_CLOEXEC
-  << FixItHint::CreateInsertion(EndLoc,
-(Twine(" | ") + SOCK_CLOEXEC).str());
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/1);
 }
 
 } // namespace android
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
@@ -90,6 +90,12 @@
   /// Helper function to get the spelling of a particular argument.
   StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult ,
int N) const;
+
+  /// Binding name of the FuncDecl of a function call.
+  static constexpr char FuncDeclBindingStr[] = "funcDecl";
+
+  /// Binding name of the function call expression.
+  static constexpr char FuncBindingStr[] = "func";
 };
 
 } // namespace android
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
@@ -20,10 +20,6 @@
 namespace android {
 
 namespace {
-
-const char *const FuncDeclBindingStr = "funcDecl";
-const char *const FuncBindingStr = "func";
-
 // Helper function to form the correct string mode for Type3.
 // Build the replace text. If it's string constant, add  directly in the
 // end of the string. Else, add .
@@ -41,6 +37,10 @@
 }
 } // namespace
 
+constexpr char CloexecCheck::FuncDeclBindingStr[];
+
+constexpr char CloexecCheck::FuncBindingStr[];
+
 void CloexecCheck::registerMatchersImpl(
 MatchFinder *Finder, internal::Matcher Function) {
   // We assume all the checked 

[clang-tools-extra] r311020 - [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Wed Aug 16 09:59:26 2017
New Revision: 311020

URL: http://llvm.org/viewvc/llvm-project?rev=311020=rev
Log:
[clang-tidy] Use CloexecCheck as base class.

Summary:
Simplify registerMatchers and check functions in CloexecCreatCheck,
CloexecSocketCheck, CloexecFopenCheck, and CloexecOpenCheck.

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


Modified:
clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.h
clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.h
clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.h
clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecSocketCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp?rev=311020=311019=311020=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.cpp Wed Aug 16 
09:59:26 2017
@@ -20,10 +20,6 @@ namespace tidy {
 namespace android {
 
 namespace {
-
-const char *const FuncDeclBindingStr = "funcDecl";
-const char *const FuncBindingStr = "func";
-
 // Helper function to form the correct string mode for Type3.
 // Build the replace text. If it's string constant, add  directly in the
 // end of the string. Else, add .
@@ -41,6 +37,10 @@ std::string buildFixMsgForStringFlag(con
 }
 } // namespace
 
+constexpr char CloexecCheck::FuncDeclBindingStr[];
+
+constexpr char CloexecCheck::FuncBindingStr[];
+
 void CloexecCheck::registerMatchersImpl(
 MatchFinder *Finder, internal::Matcher Function) {
   // We assume all the checked APIs are C functions.

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h?rev=311020=311019=311020=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCheck.h Wed Aug 16 
09:59:26 2017
@@ -90,6 +90,12 @@ protected:
   /// Helper function to get the spelling of a particular argument.
   StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
,
int N) const;
+
+  /// Binding name of the FuncDecl of a function call.
+  static constexpr char FuncDeclBindingStr[] = "funcDecl";
+
+  /// Binding name of the function call expression.
+  static constexpr char FuncBindingStr[] = "func";
 };
 
 } // namespace android

Modified: clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp?rev=311020=311019=311020=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp Wed Aug 16 
09:59:26 2017
@@ -10,7 +10,6 @@
 #include "CloexecCreatCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
@@ -21,37 +20,22 @@ namespace android {
 void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
   auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
   auto MODETType = hasType(namedDecl(hasName("mode_t")));
-
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("creat"),
-   hasParameter(0, CharPointerType),
-   hasParameter(1, MODETType))
-  .bind("funcDecl")))
-  .bind("creatFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("creat"),
+hasParameter(0, CharPointerType),
+hasParameter(1, MODETType)));
 }
 
 void CloexecCreatCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("creatFn");
-  const SourceManager  = *Result.SourceManager;
-
   const std::string  =
-  (Twine("open (") +
-   Lexer::getSourceText(CharSourceRange::getTokenRange(
-

[PATCH] D36761: [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 111372.
chh marked 3 inline comments as done.

https://reviews.llvm.org/D36761

Files:
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecCreatCheck.cpp
  clang-tidy/android/CloexecCreatCheck.h
  clang-tidy/android/CloexecFopenCheck.cpp
  clang-tidy/android/CloexecFopenCheck.h
  clang-tidy/android/CloexecOpenCheck.cpp
  clang-tidy/android/CloexecOpenCheck.h
  clang-tidy/android/CloexecSocketCheck.cpp
  clang-tidy/android/CloexecSocketCheck.h

Index: clang-tidy/android/CloexecSocketCheck.h
===
--- clang-tidy/android/CloexecSocketCheck.h
+++ clang-tidy/android/CloexecSocketCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-socket.html
-class CloexecSocketCheck : public ClangTidyCheck {
+class CloexecSocketCheck : public CloexecCheck {
 public:
   CloexecSocketCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -21,35 +20,16 @@
 static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
 
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("socket"),
-   hasParameter(0, hasType(isInteger())),
-   hasParameter(1, hasType(isInteger())),
-   hasParameter(2, hasType(isInteger(
-  .bind("funcDecl")))
-  .bind("socketFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("socket"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, hasType(isInteger())),
+hasParameter(2, hasType(isInteger();
 }
 
 void CloexecSocketCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("socketFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *FlagArg = MatchedCall->getArg(1);
-  SourceManager  = *Result.SourceManager;
-
-  if (utils::exprHasBitFlagWithSpelling(FlagArg->IgnoreParenCasts(), SM,
- Result.Context->getLangOpts(), SOCK_CLOEXEC))
-return;
-
-  SourceLocation EndLoc =
-  Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
- Result.Context->getLangOpts());
-
-  diag(EndLoc, "%0 should use %1 where possible")
-  << FD << SOCK_CLOEXEC
-  << FixItHint::CreateInsertion(EndLoc,
-(Twine(" | ") + SOCK_CLOEXEC).str());
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/1);
 }
 
 } // namespace android
Index: clang-tidy/android/CloexecOpenCheck.h
===
--- clang-tidy/android/CloexecOpenCheck.h
+++ clang-tidy/android/CloexecOpenCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -25,10 +25,10 @@
 ///
 /// Only the symbolic 'O_CLOEXEC' macro definition is checked, not the concrete
 /// value.
-class CloexecOpenCheck : public ClangTidyCheck {
+class CloexecOpenCheck : public CloexecCheck {
 public:
   CloexecOpenCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecOpenCheck.cpp
===
--- 

[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-16 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

I'll try and get you some feedback on this over the next couple of days (unless 
someone else jumps in).

Thanks for working on this!


https://reviews.llvm.org/D36527



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-16 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 111368.
Nebiroth marked 8 inline comments as done.
Nebiroth added a comment.

Fixed diff comments.


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h

Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput ) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput ) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput ) = 0;
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher , JSONOutput ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,23 @@
   ProtocolCallbacks 
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput , ProtocolCallbacks )
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP) {
+  return;
+}
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks 
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher ,
@@ -239,4 +256,7 @@
   llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler("textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -182,6 +182,9 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function that returns a path to the corresponding source file when given a header file and vice versa.
+  Path switchSourceHeader(PathRef path);
+
   /// Run formatting for \p Rng inside \p File.
   std::vector formatRange(PathRef File, Range Rng);
   /// Run formatting for the whole \p File.
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -286,3 +287,82 @@
   });
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
+
+Path ClangdServer::switchSourceHeader(PathRef path) {
+
+  std::string DEFAULT_SOURCE_EXTENSIONS[] = {
+  ".cpp", ".c", ".cc", ".cxx", ".c++", ".m", ".mm",
+  ".CPP", ".C", ".CC", ".CXX", ".C++", ".M", ".MM"};
+  std::string DEFAULT_HEADER_EXTENSIONS[] = {
+  ".h", ".hh", ".hpp", ".hxx", ".inc", ".H", ".HH", ".HPP", ".HXX", ".INC"};
+
+  const int sourceSize =
+  sizeof(DEFAULT_SOURCE_EXTENSIONS) / sizeof(DEFAULT_SOURCE_EXTENSIONS[0]);
+  const int headerSize =
+  sizeof(DEFAULT_HEADER_EXTENSIONS) / sizeof(DEFAULT_HEADER_EXTENSIONS[0]);
+
+  std::string pathDataRef = std::string(path);
+  bool isSourceFile = false, foundExtension = false;
+  SmallString<128> NewPath;
+  std::string *p;
+  p = std::find(DEFAULT_SOURCE_EXTENSIONS,
+DEFAULT_SOURCE_EXTENSIONS + sourceSize,
+llvm::sys::path::extension(path));
+  if (p != DEFAULT_SOURCE_EXTENSIONS + sourceSize) 
+  {
+std::string fileExtension = *p;
+NewPath = pathDataRef;
+pathDataRef =
+pathDataRef.substr(0, (pathDataRef.size() - fileExtension.size()));
+isSourceFile = true;
+foundExtension = true;
+  }
+
+  if (!foundExtension) {
+p = std::find(DEFAULT_HEADER_EXTENSIONS,
+  DEFAULT_HEADER_EXTENSIONS + headerSize,
+  llvm::sys::path::extension(path));
+if (p != DEFAULT_HEADER_EXTENSIONS + headerSize) {
+  std::string fileExtension = *p;
+  NewPath = pathDataRef;
+  pathDataRef =
+  pathDataRef.substr(0, (pathDataRef.size() - fileExtension.size()));
+  isSourceFile = false;
+  foundExtension = true;
+}
+  }
+
+  SmallString<128> CurrentPath;
+  CurrentPath = std::string(pathDataRef);
+  bool done = false;
+  ArrayRef ExtensionsArray;
+
+  if (!isSourceFile)
+ExtensionsArray = DEFAULT_SOURCE_EXTENSIONS;
+  else
+ExtensionsArray = DEFAULT_HEADER_EXTENSIONS;
+
+  int i = 0;
+  while (!done && i < ExtensionsArray.size()) {
+std::string CurrentPathString = CurrentPath.str();
+

[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@rjmccall Do you think that the rules for the return types in overridden 
methods that return `instancetype` should be strengthened first? For example, 
if we have the following code:

  @interface Unrelated
  - (void)method:(int)x;
  @end
  
  @interface CallsSelfSuper: NSObject
  + (void) target;
  - (void) method:(CallsSelfSuper *)x;
  @end
  
  @implementation CallsSelfSuper
  + (void) target {
[[self alloc] method: 12]; // Can't assume 'method' is CallsSelfSuper's 
'method' declaration unless we guarantee that OverrideAlloc's alloc actually 
returns `instancetype` and not id.
  }
  @end
  
  @interface OverrideAlloc: CallsSelfSuper
  @end
  
  @implementation OverrideAlloc
  + (id) alloc {
return [NSString alloc];
  }
  @end 

We can't really make any assumptions about what `[self alloc]` will return. But 
in my opinion we could assume that `[self alloc]` will return a `CallsSelfSuper 
*` if we could ensure that methods that override methods that return 
`instancetype` will compile only if they return `instancetype` type as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790



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


[PATCH] D36750: [analyzer] RetainCount: When diagnosing overrelease, mention if it's coming from a nested block.

2017-08-16 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

> By the way, plist-based tests in retain-release.m are disabled since r163536 
> (~2012), and need to be updated. It's trivial to re-enable them but annoying 
> to maintain - would we prefer to re-enable or delete them or replace with 
> -analyzer-output=text tests?

This is rdar://problem/33514142

My preference would be to factor out/re-target some specific tests into their 
own file and check that with -verify + -analyzer-output=text and with plist 
comparisons




Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:89
 ErrorReleaseNotOwned, // Release of an object that was not owned.
+ErrorReleaseNotOwnedByBlock, // Release of an object not owned by a block.
 ERROR_LEAK_START,

Is it possible to detect this from the location context in 
RetainCountChecker::processNonLeakError() rather than encoding it in the 
analysis state? This would avoid a multiplicity of 'ByBlock' kinds.


https://reviews.llvm.org/D36750



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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

The problem is that the mismatch between sections does not have to lead to any 
undesirable behavior.  Whether it does or not depends on a particular case.  I 
think we should be consistent though---if we decide that a mismatch between the 
section for a declaration and the section for a definition leads to an 
undefined behavior, then it should be so regardless of whether the sections 
were given explicitly or inferred.


https://reviews.llvm.org/D36712



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


r311013 - [OPENMP] Fix for PR28581: OpenMP linear clause - wrong results.

2017-08-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 16 08:58:46 2017
New Revision: 311013

URL: http://llvm.org/viewvc/llvm-project?rev=311013=rev
Log:
[OPENMP] Fix for PR28581: OpenMP linear clause - wrong results.

If worksharing construct has at least one linear item, an implicit
synchronization point must be emitted to avoid possible conflict with
the loading/storing values to the original variables. Added implicit
barrier if the linear item is found before actual start of the
worksharing construct.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_linear_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=311013=311012=311013=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Aug 16 08:58:46 2017
@@ -1231,12 +1231,14 @@ void CodeGenFunction::EmitOMPInnerLoop(
   EmitBlock(LoopExit.getBlock());
 }
 
-void CodeGenFunction::EmitOMPLinearClauseInit(const OMPLoopDirective ) {
+bool CodeGenFunction::EmitOMPLinearClauseInit(const OMPLoopDirective ) {
   if (!HaveInsertPoint())
-return;
+return false;
   // Emit inits for the linear variables.
+  bool HasLinears = false;
   for (const auto *C : D.getClausesOfKind()) {
 for (auto *Init : C->inits()) {
+  HasLinears = true;
   auto *VD = cast(cast(Init)->getDecl());
   if (auto *Ref = dyn_cast(VD->getInit()->IgnoreImpCasts())) {
 AutoVarEmission Emission = EmitAutoVarAlloca(*VD);
@@ -1261,6 +1263,7 @@ void CodeGenFunction::EmitOMPLinearClaus
 EmitIgnoredExpr(CS);
   }
   }
+  return HasLinears;
 }
 
 void CodeGenFunction::EmitOMPLinearClauseFinal(
@@ -1550,7 +1553,7 @@ void CodeGenFunction::EmitOMPSimdDirecti
 CGF.EmitOMPSimdInit(S);
 
 emitAlignedClause(CGF, S);
-CGF.EmitOMPLinearClauseInit(S);
+(void)CGF.EmitOMPLinearClauseInit(S);
 {
   OMPPrivateScope LoopScope(CGF);
   CGF.EmitOMPPrivateLoopCounters(S, LoopScope);
@@ -2170,7 +2173,7 @@ bool CodeGenFunction::EmitOMPWorksharing
 
 llvm::DenseSet EmittedFinals;
 emitAlignedClause(*this, S);
-EmitOMPLinearClauseInit(S);
+bool HasLinears = EmitOMPLinearClauseInit(S);
 // Emit helper vars inits.
 
 std::pair Bounds = CodeGenLoopBounds(*this, S);
@@ -2184,7 +2187,7 @@ bool CodeGenFunction::EmitOMPWorksharing
 // Emit 'then' code.
 {
   OMPPrivateScope LoopScope(*this);
-  if (EmitOMPFirstprivateClause(S, LoopScope)) {
+  if (EmitOMPFirstprivateClause(S, LoopScope) || HasLinears) {
 // Emit implicit barrier to synchronize threads and avoid data races on
 // initialization of firstprivate variables and post-update of
 // lastprivate variables.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=311013=311012=311013=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Aug 16 08:58:46 2017
@@ -2761,7 +2761,9 @@ public:
   /// and initializes them with the values according to OpenMP standard.
   ///
   /// \param D Directive (possibly) with the 'linear' clause.
-  void EmitOMPLinearClauseInit(const OMPLoopDirective );
+  /// \return true if at least one linear variable is found that should be
+  /// initialized with the value of the original variable, false otherwise.
+  bool EmitOMPLinearClauseInit(const OMPLoopDirective );
 
   typedef const llvm::function_ref

[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Of course, right. I will change the approach.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790



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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D36712#843387, @eandrews wrote:

> Does this result in unexpected behavior though? Won't this just result in the 
> global being defined in the specified section?


If there is no section given explicitly, there is function 
SelectSectionForGlobal that will determine the section based on the properties 
of the global.  If there is code that only sees the declaration, but needs to 
know the section, it will get it from that function.  If the definition of that 
global doesn't have section either, that same function will be used, hopefully 
with the same result.  On the other hand, if the definition of the global has 
an explicit section, it may differ from the one calculated for the declarations 
of that global.  This could lead to a problem.


https://reviews.llvm.org/D36712



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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In https://reviews.llvm.org/D36712#842477, @kparzysz wrote:

> In the cases when the section is explicitly given on a definition, it was 
> likely imposed by something like the "section" attribute in the source. I 
> don't think it's unreasonable to expect that the declarations (in the 
> original source as well as in the generated IR) should carry that information 
> as well. However, since clang has apparently been ignoring that attribute on 
> declarations, it's been generating IR where declarations may not have 
> sections, but the corresponding definitions do.


Does this result in unexpected behavior though? Won't this just result in the 
global being defined in the specified section?

I can mention this case explicitly in the documentation. However I am not sure 
whether it's UB or if the global will be defined in specified section.


https://reviews.llvm.org/D36712



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


[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG




Comment at: test/clang-tidy/modernize-make-unique.cpp:253
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
 

I'd leave CHECK-FIXES with the original text to ensure no unwanted replacements 
are performed.


https://reviews.llvm.org/D36786



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-16 Thread John McCall via Phabricator via cfe-commits
rjmccall resigned from this revision.
rjmccall added a comment.

I don't think I'm best-equipped to review this, sorry.


https://reviews.llvm.org/D36527



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a nit.




Comment at: clang-tidy/android/CloexecEpollCreateCheck.cpp:27-31
+  replaceFunc(Result, /*WarningMsg=*/
+  "prefer epoll_create() to epoll_create1() "
+  "because epoll_create1() allows "
+  "EPOLL_CLOEXEC", /*FixMsg=*/
+  "epoll_create1(EPOLL_CLOEXEC)");

nit: Please remove argument comments, they don't add any useful information.


https://reviews.llvm.org/D35367



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


[PATCH] D35363: [clang-tidy] Add a close-on-exec check on accept4() in Android module.

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35363



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


[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a nit.




Comment at: clang-tidy/android/CloexecAcceptCheck.cpp:42
+  "prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC",
+  /*FixMsg=*/ReplacementText);
+}

Two minor issues here:
1. `FixMsg` name is misleading, specifically the "Msg" part, since it's not a 
message.
2. there's no need to use an argument comment, where it's clear what the actual 
argument's meaning is. E.g. `ReplacementText` is pretty clear on its own. As is 
the warning message above.


https://reviews.llvm.org/D35362



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


[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35365



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


[PATCH] D35678: Omit sumbodule semantics for TS modules

2017-08-16 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

In https://reviews.llvm.org/D35678#842891, @rsmith wrote:

> I'd still like the id flattening moved to the caller. [...] I'm fine with 
> that being done as a separate change after this one, though, if you'd prefer.


Yes, that would probably be easier.

> Do you need someone to commit this for you?

Yes, please, I don't have commit rights. Though if I were given them, I could 
do that myself (and it would also help with the other patch, I guess).


https://reviews.llvm.org/D35678



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


[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread John McCall via Phabricator via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

Class methods can be inherited; this entire approach is bogus.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34440#843192, @vladimir.plyashkun wrote:

> @alexfh
>  Thanks for the response!
>  Yes, we re-implemented logic and now use JSON compilation database to pass 
> compiler options to Clang-Tidy.
>  Anyway, i think in general it's useful to support @response_files, see my 
> comment: https://reviews.llvm.org/D34440#813411


If you see value in supporting response files and are willing to invest more 
time in the implementation, I'll expand a bit on 
https://reviews.llvm.org/D34440#809529. Since the primary use case for 
@response_files is to work around the command line length limit, and, as Anton 
pointed out, they can be generated by build systems on the fly (both only 
relevant on Windows, I guess), they may be valuable for passing compiler 
arguments (they can grow really large) and less so for other arguments of Clang 
tools. So it seems like the right place to expand response files is where the 
compiler arguments are retrieved from the compilation database. However, a bit 
of extra attention may be needed to properly handle the use case of Clang 
tooling as a library with in-memory files system (where we probably don't want 
to read random response files that compiler arguments in the compilation 
database refer to).


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-08-16 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Thanks for doing this!


https://reviews.llvm.org/D36737



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


[PATCH] D36410: [OpenCL] Handle taking address of block captures

2017-08-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Sorry for the delay.

I feel forbidding user taking address of captured variable is too restrictive 
and make blocks less useful.

A block is quite like a normal function with a generic pointer argument. Users 
take the responsibility to make sure the cast of a generic pointer to private 
or global address space is valid at runtime.

I am more inclined to the alternative approach, i.e., assuming captures are 
located in the generic AS implicitly.


https://reviews.llvm.org/D36410



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


[PATCH] D36712: Emit section information for extern variables

2017-08-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 111341.
eandrews added a comment.

Corrected spelling error.


https://reviews.llvm.org/D36712

Files:
  docs/LangRef.rst


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -622,6 +622,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that its definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -622,6 +622,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that its definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35200: Don't use mmap on Windows

2017-08-16 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a reviewer: ilya-biryukov.
nik added a comment.

Ping.

I guess locking the file less helps also clangd?!


https://reviews.llvm.org/D35200



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


[PATCH] D36794: Fixups to FE tests affected by D36793

2017-08-16 Thread coby via Phabricator via cfe-commits
coby created this revision.
Herald added a subscriber: eraman.

Repository:
  rL LLVM

https://reviews.llvm.org/D36794

Files:
  test/CodeGen/mozilla-ms-inline-asm.c
  test/CodeGen/ms-inline-asm-64.c
  test/CodeGen/ms-inline-asm.c
  test/CodeGen/ms-inline-asm.cpp
  test/CodeGenCXX/ms-inline-asm-return.cpp
  test/Sema/ms-inline-asm.c

Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -42,7 +42,7 @@
 void t6(void) {
   __asm int 0x2c
 // CHECK: t6
-// CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", "~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t7() {
@@ -61,7 +61,7 @@
 mov eax, ebx
   }
 // CHECK: t7
-// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$44", "~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "mov eax, ebx", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -94,7 +94,7 @@
 // CHECK: t9
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$0x07
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -229,7 +229,7 @@
   __asm mov eax, LENGTH _bar
 // CHECK: mov eax, $$2
   __asm mov eax, [eax + LENGTH foo * 4]
-// CHECK: mov eax, [eax + $$1 * $$4]
+// CHECK: mov eax, [eax + $$4]
 
   __asm mov eax, TYPE foo
 // CHECK: mov eax, $$4
@@ -240,16 +240,16 @@
   __asm mov eax, TYPE _bar
 // CHECK: mov eax, $$1
   __asm mov eax, [eax + TYPE foo * 4]
-// CHECK: mov eax, [eax + $$4 * $$4]
+// CHECK: mov eax, [eax + $$16]
 
   __asm mov eax, SIZE foo
 // CHECK: mov eax, $$4
   __asm mov eax, SIZE bar
 // CHECK: mov eax, $$1
   __asm mov eax, SIZE _foo
 // CHECK: mov eax, $$16
   __asm mov eax, [eax + SIZE _foo * 4]
-// CHECK: mov eax, [eax + $$16 * $$4]
+// CHECK: mov eax, [eax + $$64]
   __asm mov eax, SIZE _bar
 // CHECK: mov eax, $$2
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
@@ -265,7 +265,7 @@
 // CHECK: t21
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$07H
+// CHECK-SAME: mov ebx, $$7
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -312,13 +312,13 @@
 void t25() {
 // CHECK: t25
   __asm mov eax, 0h
-// CHECK: mov eax, $$0h
+// CHECK: mov eax, $$4294967295
   __asm mov eax, 0fhU
 // CHECK: mov eax, $$15
   __asm mov eax, 0a2h
-// CHECK: mov eax, $$0a2h
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010b
-// CHECK: mov eax, $$10100010b
+// CHECK: mov eax, $$162
   __asm mov eax, 10100010BU
 // CHECK: mov eax, $$162
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
@@ -344,7 +344,7 @@
 void t27() {
   __asm mov eax, fs:[0h]
 // CHECK: t27
-// CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0h]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t28() {
@@ -426,49 +426,49 @@
 void t34() {
 // CHECK: t34
   __asm prefetchnta 64[eax]
-// CHECK: prefetchnta $$64[eax]
+// CHECK: prefetchnta [eax + $$64]
   __asm mov eax, dword ptr 4[eax]
-// CHECK: mov eax, dword ptr $$4[eax]
+// CHECK: mov eax, dword ptr [eax + $$4]
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t35() {
 // CHECK: t35
   __asm prefetchnta [eax + (200*64)]
-// CHECK: prefetchnta [eax + ($$200*$$64)]
+// CHECK: prefetchnta [eax + $$12800]
   __asm mov eax, dword ptr [eax + (200*64)]
-// CHECK: mov eax, dword ptr [eax + ($$200*$$64)]
+// CHECK: mov eax, dword ptr [eax + $$12800]
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t36() {
 // CHECK: t36
   int arr[4];
   // Work around PR20368: These should be single line blocks
   __asm { mov eax, 4[arr] }
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect "mov eax, $0[$$4]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
   __asm { mov eax, 4[arr + 4] }
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect "mov eax, $0[$$8]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
   __asm { mov eax, 8[arr + 4 + 32*2 - 4] }
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect "mov eax, $0[$$72]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
   __asm { mov eax, 12[4 + arr] }
-// CHECK: call 

r311007 - [OPRNMP] Fix for PR33445: ICE: OpenMP target containing ordered for.

2017-08-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 16 07:01:00 2017
New Revision: 311007

URL: http://llvm.org/viewvc/llvm-project?rev=311007=rev
Log:
[OPRNMP] Fix for PR33445: ICE: OpenMP target containing ordered for.

If exceptions are enabled, there may be a problem with the codegen of
the finalization functions from OpenMP runtime. It happens because of
the problem with the getting of thread identifier value. Patch tries to
fix it by using the result of the call of function
__kmpc_global_thread_num() rather than loading of value of outlined
function parameter.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/critical_codegen.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_simd_codegen.cpp
cfe/trunk/test/OpenMP/master_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/parallel_sections_codegen.cpp
cfe/trunk/test/OpenMP/sections_codegen.cpp
cfe/trunk/test/OpenMP/single_codegen.cpp
cfe/trunk/test/OpenMP/taskgroup_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=311007=311006=311007=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Aug 16 07:01:00 2017
@@ -1438,19 +1438,22 @@ llvm::Value *CGOpenMPRuntime::getThreadI
 if (ThreadID != nullptr)
   return ThreadID;
   }
-  if (auto *OMPRegionInfo =
-  dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->getThreadIDVariable()) {
-  // Check if this an outlined function with thread id passed as argument.
-  auto LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
-  ThreadID = CGF.EmitLoadOfLValue(LVal, Loc).getScalarVal();
-  // If value loaded in entry block, cache it and use it everywhere in
-  // function.
-  if (CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
-auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
-Elem.second.ThreadID = ThreadID;
+  // If exceptions are enabled, do not use parameter to avoid possible crash.
+  if (!CGF.getInvokeDest()) {
+if (auto *OMPRegionInfo =
+dyn_cast_or_null(CGF.CapturedStmtInfo)) {
+  if (OMPRegionInfo->getThreadIDVariable()) {
+// Check if this an outlined function with thread id passed as 
argument.
+auto LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
+ThreadID = CGF.EmitLoadOfLValue(LVal, Loc).getScalarVal();
+// If value loaded in entry block, cache it and use it everywhere in
+// function.
+if (CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
+  auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
+  Elem.second.ThreadID = ThreadID;
+}
+return ThreadID;
   }
-  return ThreadID;
 }
   }
 

Modified: cfe/trunk/test/OpenMP/critical_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/critical_codegen.cpp?rev=311007=311006=311007=diff
==
--- cfe/trunk/test/OpenMP/critical_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/critical_codegen.cpp Wed Aug 16 07:01:00 2017
@@ -78,7 +78,7 @@ void critical_ref(S ) {
 void parallel_critical() {
 #pragma omp parallel
 #pragma omp critical
-  // TERM_DEBUG-NOT: __kmpc_global_thread_num
+  // TERM_DEBUG: __kmpc_global_thread_num
   // TERM_DEBUG: call void @__kmpc_critical({{.+}}), !dbg 
[[DBG_LOC_START:![0-9]+]]
   // TERM_DEBUG: invoke void {{.*}}foo{{.*}}()
   // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.cpp?rev=311007=311006=311007=diff
==
--- cfe/trunk/test/OpenMP/for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_codegen.cpp Wed Aug 16 07:01:00 2017
@@ -355,7 +355,7 @@ int foo() {return 0;};
 void parallel_for(float *a) {
 #pragma omp parallel
 #pragma omp for schedule(static, 5)
-  // TERM_DEBUG-NOT: __kmpc_global_thread_num
+  // TERM_DEBUG: __kmpc_global_thread_num
   // TERM_DEBUG: call void @__kmpc_for_static_init_4u({{.+}}), !dbg 
[[DBG_LOC_START:![0-9]+]]
   // TERM_DEBUG: invoke i32 {{.*}}foo{{.*}}()
   // TERM_DEBUG: unwind label %[[TERM_LPAD:.+]],

Modified: cfe/trunk/test/OpenMP/for_simd_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_codegen.cpp?rev=311007=311006=311007=diff
==
--- cfe/trunk/test/OpenMP/for_simd_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_codegen.cpp Wed Aug 16 

[PATCH] D36672: [clang-tidy] readability-non-const-parameter: fixit on all function declarations

2017-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:146
+
+if (const auto *Parent = Par->getParentFunctionOrMethod()) {
+  if (const auto *F = dyn_cast(Parent)) {

Please do not use `auto` here, as the type is not spelled out in the 
initialization.



Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:147
+if (const auto *Parent = Par->getParentFunctionOrMethod()) {
+  if (const auto *F = dyn_cast(Parent)) {
+const auto ParDecl =

What if the parent is an `ObjCMethodDecl` instead?



Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:148-152
+const auto ParDecl =
+F->getFirstDecl()->getParamDecl(Par->getFunctionScopeIndex());
+if (Par != ParDecl)
+  D << ParDecl->getName()
+<< FixItHint::CreateInsertion(ParDecl->getLocStart(), "const ");

Don't we need the fixit for *all* declarations of the function? e.g.,
```
char f(char *c); // Need it here
char f(char *c); // And here

char f(char *c) { // And here
  return *c;
}
```


Repository:
  rL LLVM

https://reviews.llvm.org/D36672



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:191
+  // Initialization of owners.
+  else if (OwnerInitialization != nullptr) {
+diag(OwnerInitialization->getLocStart(),

aaron.ballman wrote:
> No else after a return. Same applies elsewhere.
Please remove the use of `CheckApplied`. The early returns were fine, it's the 
complex if/else logic that should be modified. e.g.,
```
if (OwnerAssignment) {
  
  return true;
}

if (OwnerInitialization) {
  
  return true;
}
...
return false;
```


https://reviews.llvm.org/D36354



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


[PATCH] D36790: [ObjC] Messages to 'self' in class methods should use class method dispatch to avoid multiple method ambiguities

2017-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Prior to this patch, messages to `self` in class methods were treated as 
instance methods to a `Class` value. When these methods returned `instancetype` 
the compiler only saw `id` through the `instancetype`, and not the `Interface 
*`. This caused problems when that return value was a receiver in a message 
send, as the compiler couldn't select the right method declaration and had to 
rely on a selection from the global method pool.

This patch modifies the semantics of such message sends and uses class messages 
that are dispatched to the interface that corresponds to the class that 
contains the class method. This ensures that `instancetype`s are correctly 
interpreted by the compiler. This is an ARC only change, since non-ARC code can 
reassign `self`. The type `dectltype(self)` is used to store the `self` 
receiver in the class message to ensure that `self` remains in the AST.

Thanks for taking a look.

rdar://20940997


Repository:
  rL LLVM

https://reviews.llvm.org/D36790

Files:
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/multiple-method-names-class-self.m


Index: test/SemaObjC/multiple-method-names-class-self.m
===
--- /dev/null
+++ test/SemaObjC/multiple-method-names-class-self.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -Wobjc-multiple-method-names -x objective-c -verify %s
+// RUN: %clang_cc1 -Wobjc-multiple-method-names -x objective-c -verify 
-fobjc-arc -DARC %s
+#ifdef ARC
+// expected-no-diagnostics
+#endif
+
+@interface NSObj
+
++ (instancetype) alloc;
+
+@end
+
+@interface SelfAllocReturn: NSObj
+
+- (instancetype)initWithFoo:(int)x;
+#ifndef ARC
+// expected-note@-2 {{using}}
+#endif
+
+@end
+
+@interface SelfAllocReturn2: NSObj
+
+- (instancetype)initWithFoo:(SelfAllocReturn *)x;
+#ifndef ARC
+// expected-note@-2 {{also found}}
+#endif
+
+@end
+
+@implementation SelfAllocReturn
+
+- (instancetype)initWithFoo:(int)x {
+return self;
+}
+
++ (instancetype) thingWithFoo:(int)x {
+return [[self alloc] initWithFoo: x];
+#ifndef ARC
+// expected-warning@-2 {{multiple methods named 'initWithFoo:' found}}
+#endif
+}
+
+@end
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1320,9 +1320,11 @@
   }
   }
 
-  //   - if the receiver is the name of a class U, T is a pointer to U
+  //   - if the receiver is the name of a class U, T is a pointer to U. U 
should
+  // be desugared to avoid 'decltype(self)' propagation.
   if (ReceiverType->getAsObjCInterfaceType())
-return transferNullability(Context.getObjCObjectPointerType(ReceiverType));
+return transferNullability(Context.getObjCObjectPointerType(
+ReceiverType.getDesugaredType(Context)));
   //   - if the receiver is of type Class or qualified Class type,
   // T is the declared return type of the method.
   if (ReceiverType->isObjCClassType() ||
@@ -2738,10 +2740,31 @@
 } else if (ReceiverType->isObjCClassOrClassKindOfType() ||
ReceiverType->isObjCQualifiedClassType()) {
   // Handle messages to Class.
+  // Treat messages to 'self' in class methods as class messages when ARC
+  // is enabled (because self can't be reassigned when ARC is on).
+  if (Receiver->isObjCSelfExpr() && getLangOpts().ObjCAutoRefCount) {
+assert(ReceiverType->isObjCClassType() && "expected a Class self");
+const ObjCMethodDecl *MD = cast(
+cast(
+cast(Receiver->IgnoreParenImpCasts())->getDecl())
+->getDeclContext());
+assert(MD->isClassMethod() && "expected a class method");
+QualType ReceiverType =
+Context.getObjCInterfaceType(MD->getClassInterface());
+// Use a pseudo-decltype type to keep the expression in the AST.
+assert(!Receiver->isInstantiationDependent() &&
+   "unexpected dependent expr");
+ReceiverType = Context.getDecltypeType(Receiver, ReceiverType);
+return BuildClassMessage(
+Context.getTrivialTypeSourceInfo(ReceiverType, LBracLoc),
+ReceiverType,
+/*SuperLoc=*/SourceLocation(), Sel,
+/*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, ArgsIn);
+  }
   // We allow sending a message to a qualified Class ("Class"), which
   // is ok as long as one of the protocols implements the selector (if not,
   // warn).
-  if (!ReceiverType->isObjCClassOrClassKindOfType()) {
+  else if (!ReceiverType->isObjCClassOrClassKindOfType()) {
 const ObjCObjectPointerType *QClassTy
   = ReceiverType->getAsObjCQualifiedClassType();
 // Search protocols for class methods.


Index: test/SemaObjC/multiple-method-names-class-self.m
===
--- /dev/null
+++ test/SemaObjC/multiple-method-names-class-self.m
@@ -0,0 +1,44 

[PATCH] D36410: [OpenCL] Handle taking address of block captures

2017-08-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Ping! :)


https://reviews.llvm.org/D36410



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-08-16 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

@alexf
Thanks for the response!
Yes, we re-implemented logic and now use JSON compilation database to pass 
compiler options to Clang-Tidy.
Anyway, i think in general it's useful to support @response_files, see my 
comment: https://reviews.llvm.org/D34440#813411


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D36686: [clang-diff] Add option to compare files across git revisions

2017-08-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 111328.
johannes edited the summary of this revision.
johannes added a comment.

accept a commit range


https://reviews.llvm.org/D36686

Files:
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -16,6 +16,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Program.h"
 
 using namespace llvm;
 using namespace clang;
@@ -33,9 +34,9 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
-static cl::opt
-PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
- cl::init(false), cl::cat(ClangDiffCategory));
+static cl::opt PrintMatches("dump-matches",
+  cl::desc("Print the matched nodes."),
+  cl::init(false), cl::cat(ClangDiffCategory));
 
 static cl::opt HtmlDiff("html",
   cl::desc("Output a side-by-side diff in HTML."),
@@ -55,6 +56,12 @@
   cl::Optional, cl::init(""),
   cl::cat(ClangDiffCategory));
 
+static cl::opt
+GitRevision("git-rev",
+cl::desc("Compare a file between a revision range (..HEAD "
+ "is assumed if a single revision is given."),
+cl::Optional, cl::init(""), cl::cat(ClangDiffCategory));
+
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -438,6 +445,19 @@
   }
 }
 
+std::string Exec(const char *Command) {
+  char Buffer[128];
+  std::string Result;
+  std::shared_ptr Pipe(popen(Command, "r"), pclose);
+  if (!Pipe)
+return Result;
+  while (!feof(Pipe.get())) {
+if (fgets(Buffer, 128, Pipe.get()) != nullptr)
+  Result += Buffer;
+  }
+  return Result;
+}
+
 int main(int argc, const char **argv) {
   std::string ErrorMessage;
   std::unique_ptr CommonCompilations =
@@ -473,13 +493,55 @@
 return 0;
   }
 
-  if (DestinationPath.empty()) {
+  if (DestinationPath.empty() && GitRevision.empty()) {
 llvm::errs() << "Error: Exactly two paths are required.\n";
 return 1;
   }
 
-  std::unique_ptr Src = getAST(CommonCompilations, SourcePath);
-  std::unique_ptr Dst = getAST(CommonCompilations, DestinationPath);
+  std::unique_ptr Src, Dst;
+
+  if (!GitRevision.empty()) {
+std::string Git;
+auto ErrorOrGit = llvm::sys::findProgramByName("git");
+if (!ErrorOrGit) {
+  llvm::errs() << "Error: Could not find git executable.\n";
+  return 1;
+}
+Git = ErrorOrGit.get();
+if (GitRevision.find("..") == std::string::npos)
+  GitRevision += "..HEAD";
+size_t Dots = GitRevision.find("..");
+GitRevision.replace(Dots, 2, "  ");
+GitRevision += " HEAD";
+std::string RevParseCommand = "git rev-parse " + GitRevision;
+std::string Revisions = Exec(RevParseCommand.data());
+std::transform(Revisions.begin(), Revisions.end(), Revisions.begin(),
+   [](char C) { return C == '\n' ? '\0' : C; });
+auto SrcRev = Revisions.data();
+size_t Offset = Revisions.find('\0') + 1;
+auto DstRev = Revisions.data() + Offset;
+auto UserRev = Revisions.data() + Revisions.find('\0', Offset) + 1;
+const char *Checkout[] = {"git", "checkout", nullptr, nullptr};
+auto checkout = [&](const char *Rev) {
+  Checkout[2] = Rev;
+  if (llvm::sys::ExecuteAndWait(Git, Checkout)) {
+llvm::errs() << "Error: Failed to checkout " << Rev << "\n";
+return false;
+  }
+  return true;
+};
+if (!checkout(SrcRev))
+  return 1;
+Src = getAST(CommonCompilations, SourcePath);
+if (!checkout(DstRev))
+  return 1;
+Dst = getAST(CommonCompilations, SourcePath);
+checkout(UserRev);
+  } else {
+Src = getAST(CommonCompilations, SourcePath);
+Dst = getAST(CommonCompilations, DestinationPath);
+  }
+
   if (!Src || !Dst)
 return 1;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-16 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

Ping


https://reviews.llvm.org/D36527



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-08-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34440#825924, @vladimir.plyashkun wrote:

> > Many build systems normally generate response files on-fly in some 
> > circumstances (e.g. if command line is longer than some platform-imposed 
> > limit). So IMO response files should be a perfect citizen here.
>
> friendly ping


Sorry for the delay. I lost track of this revision somehow.

Have you found an alternative solution or are you still interested in 
implementing this functionality?


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D36761: [clang-tidy] Use CloexecCheck as base class.

2017-08-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with a few nits.




Comment at: clang-tidy/android/CloexecCheck.h:95
+  /// Binding name of the FuncDecl of a function call.
+  static const char *FuncDeclBindingStr;
+

nit: use `static constexpr char FuncDeclBindingStr[] ="..."`, the same below.



Comment at: clang-tidy/android/CloexecFopenCheck.cpp:31
 void CloexecFopenCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("fopenFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *ModeArg = MatchedCall->getArg(1);
-
-  // Check if the 'e' may be in the mode string.
-  const auto *ModeStr = dyn_cast(ModeArg->IgnoreParenCasts());
-  if (!ModeStr || (ModeStr->getString().find(MODE) != StringRef::npos))
-return;
-
-  const std::string  = BuildReplaceText(
-  ModeArg, *Result.SourceManager, Result.Context->getLangOpts());
-
-  diag(ModeArg->getLocStart(), "use %0 mode 'e' to set O_CLOEXEC")
-  << FD
-  << FixItHint::CreateReplacement(ModeArg->getSourceRange(),
-  ReplacementText);
+  insertStringFlag(Result, 'e', 1);
 }

nit: add `/*Mode=*/'e', /*ArgsPos=*/1`, the same to other places.



Comment at: clang-tidy/android/CloexecOpenCheck.cpp:37
+  const auto *FD = Result.Nodes.getNodeAs(FuncDeclBindingStr);
+  int ArgPos = (FD->param_size() > 2) ? 2 : 1;
+  insertMacroFlag(Result, "O_CLOEXEC", ArgPos);

Should we check or assert `FD->param_size() > 0`?


https://reviews.llvm.org/D36761



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-08-16 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko updated this revision to Diff 111322.
m.ostapenko added a comment.

Ping^3


Repository:
  rL LLVM

https://reviews.llvm.org/D16403

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/scopes-cfg-output.cpp

Index: test/Analysis/scopes-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/scopes-cfg-output.cpp
@@ -0,0 +1,1098 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+class A {
+public:
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  A() {}
+
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  ~A() {}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2: 1
+// CHECK-NEXT:   3: return [B1.2];
+// CHECK-NEXT:   4: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  operator int() const { return 1; }
+};
+
+int getX();
+extern const bool UV;
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: a
+// CHECK-NEXT:   5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:   6: const A  = a;
+// CHECK-NEXT:   7: A() (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: [B1.7] (BindTemporary)
+// CHECK-NEXT:   9: [B1.8] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:  10: [B1.9]
+// CHECK-NEXT:  11: const A  = A();
+// CHECK-NEXT:  12: [B1.11].~A() (Implicit destructor)
+// CHECK-NEXT:  13: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  14: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+void test_const_ref() {
+  A a;
+  const A& b = a;
+  const A& c = A();
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:   3: A a[2];
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:   5: A b[0];
+// CHECK-NEXT:   6: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   7: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   6: A c;
+// CHECK-NEXT:   7:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: A d;
+// CHECK-NEXT:   9: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT:  10: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:  11: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:  12:  (CXXConstructExpr, class A)
+// CHECK-NEXT:  13: A b;
+// CHECK-NEXT:  14: [B1.13].~A() (Implicit destructor)
+// CHECK-NEXT:  15: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  16: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B3
+// CHECK:  [B1]
+// CHECK-NEXT:   1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   2: A c;
+// CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   6: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B2]
+// CHECK-NEXT:   1: CFGScopeBegin(IfStmt)
+// CHECK-NEXT:   2: return;
+// CHECK-NEXT:   3: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B3]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// 

[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-16 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added inline comments.



Comment at: clang/lib/Driver/DriverOptions.cpp:14
 #include "llvm/Option/Option.h"
+#include 
 

I think the C++ version of the assert header is more consistent: `#include 
`



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:313
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "assert(";
+OS << "Opt.addValues(";

Don't call this inside an assert itself. The call would be removed on release 
builds (where assert is a no-op) and we wouldn't do the `addValues` anymore 
which breaks everything silently in release builds. Try something like this:

```
  bool ValuesWereAdded = Opt.addValues(...);
  (void)ValuesWereAdded; // Prevents unused variable warnings
  assert(ValuesWereAdded && "Couldn't add values to OptTable!");
```


https://reviews.llvm.org/D36782



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


[PATCH] D36786: [clang-tidy] Don't generate fixes for initializer_list constructor in make_unique check.

2017-08-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: xazax.hun, JDevlieghere.

The current fix will break the compilation -- because braced list is not
deducible in std::make_unique (with the use of forwarding) without
specifying the type explicitly.

We could support it in the future.


https://reviews.llvm.org/D36786

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -250,7 +250,6 @@
   // Initialization with the initializer-list constructor.
   std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
 
   // Initialization with default constructor.
   std::unique_ptr PF1 = std::unique_ptr(new F());
@@ -265,33 +264,27 @@
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF3 = std::unique_ptr(new F{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF3 = std::make_unique({1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF4 = std::unique_ptr(new F{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF4 = std::make_unique({1, 2});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PF5 = std::unique_ptr(new F({1, 2}));
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PF5 = std::make_unique({1, 2});
 
   // Initialization with the initializer-list constructor as the default
   // constructor is not present.
   std::unique_ptr PG1 = std::unique_ptr(new G{});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG1 = std::make_unique({});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG2 = std::unique_ptr(new G{1});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG2 = std::make_unique({1});
 
   // Initialization with the initializer-list constructor.
   std::unique_ptr PG3 = std::unique_ptr(new G{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PG3 = std::make_unique({1, 2});
 
   std::unique_ptr FF = std::unique_ptr(new Foo());
   // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -274,19 +274,17 @@
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
   if (NewConstruct->isStdInitListInitialization()) {
-// Direct Initialization with the initializer-list constructor.
-//   struct S { S(std::initializer_list); };
+// FIXME: Add fixes for direct initialization with the initializer-list
+// constructor. Unlike ordinal cases, braced list can not be deduced in
+// std::make_smart_ptr, we need to specify the type explicitly in the
+// fixes, see below.
+//   struct S { S(std::initializer_list); };
 //   smart_ptr(new S{1, 2, 3});
 //   smart_ptr(new S{}); // use initializer-list consturctor
 // The brace has to be kept, so this has to be replaced with:
-//   std::make_smart_ptr({1, 2, 3});
-//   std::make_smart_ptr({});
-unsigned NumArgs = NewConstruct->getNumArgs();
-if (NumArgs == 0) {
-  return;
-}
-InitRange = SourceRange(NewConstruct->getArg(0)->getLocStart(),
-NewConstruct->getArg(NumArgs - 
1)->getLocEnd());
+//   std::make_smart_ptr(std::initializer_list({1, 2, 3}));
+//   std::make_smart_ptr(std::initializer_list({}));
+return;
   } else {
 // Direct initialization with ordinary constructors.
 //   struct S { S(int x); S(); };


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -250,7 +250,6 @@
   // Initialization with the initializer-list constructor.
   std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
-  // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2});
 
   // Initialization with default constructor.
   std::unique_ptr PF1 = std::unique_ptr(new F());
@@ -265,33 +264,27 @@
   // 

[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-16 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111318.
yamaguchi marked 7 inline comments as done.
yamaguchi added a comment.

Update diff according to Raphael's comments.


https://reviews.llvm.org/D36782

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Driver/DriverOptions.cpp
  clang/test/Driver/autocomplete.c
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -298,5 +298,29 @@
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
+
+  OS << "\n";
+  OS << "#ifdef OPTTABLE_ARG_INIT\n";
+  OS << "//\n";
+  OS << "// Option Values\n\n";
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
+if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << "{\n";
+  OS << R.getValueAsString("ValuesCode");
+  OS << "\n";
+  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+OS << "assert(";
+OS << "Opt.addValues(";
+std::string S = (Pref + R.getValueAsString("Name")).str();
+write_cstring(OS, S);
+OS << ", Values)";
+OS << ");\n";
+  }
+  OS << "}\n";
+}
+  }
+  OS << "\n";
+  OS << "#endif // OPTTABLE_ARG_INIT\n";
 }
 } // end namespace llvm
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -196,7 +196,7 @@
 
 // Returns true if one of the Prefixes + In.Names matches Option
 static bool optionMatches(const OptTable::Info , StringRef Option) {
-  if (In.Values && In.Prefixes)
+  if (In.Prefixes)
 for (size_t I = 0; In.Prefixes[I]; I++)
   if (Option == std::string(In.Prefixes[I]) + In.Name)
 return true;
@@ -209,8 +209,9 @@
 std::vector
 OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
   // Search all options and return possible values.
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
-if (!optionMatches(In, Option))
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
+if (!In.Values || !optionMatches(In, Option))
   continue;
 
 SmallVector Candidates;
@@ -228,7 +229,8 @@
 std::vector
 OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
   std::vector Ret;
-  for (const Info  : OptionInfos.slice(FirstSearchableIndex)) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+const Info  = OptionInfos[I];
 if (!In.Prefixes || (!In.HelpText && !In.GroupID))
   continue;
 if (In.Flags & DisableFlags)
@@ -245,6 +247,17 @@
   return Ret;
 }
 
+bool OptTable::addValues(const char *Option, const char *Values) {
+  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
+Info  = OptionInfos[I];
+if (optionMatches(In, Option)) {
+  In.Values = Values;
+  return true;
+}
+  }
+  return false;
+}
+
 Arg *OptTable::ParseOneArg(const ArgList , unsigned ,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
@@ -256,8 +269,8 @@
   if (isInput(PrefixesUnion, Str))
 return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
 
-  const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
-  const Info *End = OptionInfos.end();
+  const Info *Start = OptionInfos.data() + FirstSearchableIndex;
+  const Info *End = OptionInfos.data() + OptionInfos.size();
   StringRef Name = StringRef(Str).ltrim(PrefixChars);
 
   // Search for the first next option which could be a prefix.
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -57,8 +57,8 @@
   };
 
 private:
-  /// \brief The static option information table.
-  ArrayRef OptionInfos;
+  /// \brief The non-static option information table.
+  std::vector OptionInfos;
   bool IgnoreCase;
 
   unsigned TheInputOptionID = 0;
@@ -143,6 +143,17 @@
   std::vector findByPrefix(StringRef Cur,
 unsigned short DisableFlags) const;
 
+  /// Add Values to Option's Values class
+  ///
+  /// \param [in] Option - Prefix + Name of the flag which Values will be
+  ///  changed. For example, "-analyzer-checker".
+  /// \param [in] Values - String of Values seperated by ",", such as
+  ///  "foo, bar..", where foo and bar is the argument which the Option flag
+  //  takes
+  ///
+  /// \return true in success, and false in fail.
+  bool addValues(const char *Option, const char *Values);
+
   /// \brief Parse a single argument; returning the 

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-16 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: unittests/Format/FormatTest.cpp:2281
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
   verifyFormat("#define A \\\n"

mzeren-vmw wrote:
> mzeren-vmw wrote:
> > Experimenting with the patch locally I found that comment indentation is 
> > broken in some cases. Please add tests that cover comments. For example:
> > 
> > comment indented at code level as expected:
> >   void f() {
> >   #if 0
> > // Comment
> > code();
> >   #  define FOO 0
> >   #endif
> >   }
> > comment not indented at code level when there's a guard:
> >   #ifndef _SOMEFILE_H
> >   #define _SOMEFILE_H
> >   void f() {
> >   #if 0
> >   // Comment
> > code();
> >   #  define FOO 0
> >   #endif
> >   }
> >   #endif
> > 
> > The `#define FOO 0` is required to trigger this behavior.
> Erik spent some time investigating issues with comment indentation. A couple 
> of insights so far:
> 
> a) We need tests for wrapped macros (with trailing \ continuations). These 
> need to include embedded comments.
> 
> b) It would be most natural to align comments with the following non-comment 
> line. So a comment may be indented at "preprocessor level" or "code level". 
> If indented at preprocessor level we have to handle the extra space 
> introduced by the leading hash. This may require an extra bit per line to 
> indicate whether the "aligned-to" line is preprocessor or code.
"#if 0" specifically might not be a good candidate for a test case as that 
should be treated like a comment. We should not try to format anything inside a 
"#if 0" and I'd be surprised if clang-format touched that at all. "#if A" or 
something is more appropriate.



Comment at: unittests/Format/FormatTest.cpp:2322-2331
+  // Test with include guards.
+  EXPECT_EQ("#ifndef _SOMEFILE_H\n"
+"#define _SOMEFILE_H\n"
+"code();\n"
+"#endif",
+format("#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"

mzeren-vmw wrote:
> A DRY-er way to say this is:
>   auto WithGuard = "#ifndef _SOMEFILE_H\n"
>"#define _SOMEFILE_H\n"
>"code();\n"
>"#endif";
>   ASSERT_EQ(WithGuards, format(WithGuards, Style));
> 
I think _A... is actually not an identifier that is ok to use. Remove the 
leading "_".



Comment at: unittests/Format/FormatTest.cpp:2334
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"

mzeren-vmw wrote:
> 
> It would be nice to have a comment that explains why you cannot use 
> verifyFormat.
Or even have a separate function that messes this up in some other way, not 
altering line breaks so that we can keep these tests short.



Comment at: unittests/Format/FormatTest.cpp:2405-2408
+  // Defect: We currently do not deal with cases where legitimate lines may be
+  // outside an include guard. Examples are #pragma once and
+  // #pragma GCC diagnostic, or anything else that does not change the meaning
+  // of the file if it's included multiple times.

euhlmann wrote:
> mzeren-vmw wrote:
> > We need to handle comments (like copyrights) before the include guard. 
> > There is an analogous problem with trailing blank lines, or trailing 
> > comments.
> > 
> > I think we need a small state machine: Init, Start, Open, Closed, NotGuard 
> > (terminal). `FoundIncludeGuardStart` should change from a bool to an enum 
> > to track this state. `PPMaybeIncludeGuard` can then drop it's "mabye". 
> > Whether or not it is null depends directly on the state. It does not 
> > determine state itself. While parsing, each line updates the state. If we 
> > get to `eof` in the Closed state then we have detected an include guard. 
> > ... Or similar logic
> > 
> > Note that support for comments before the guard opens the door to support 
> > for #pragma once. It is tempting to add that, but that is a slippery slope. 
> > I would recommend leaving that as a defect that can be addressed later.
> @djasper @klimek
> Do you have any comments on this? I've begun to implement an enum/state 
> machine but I'd like to know if you'd like me to implement a different way.
Most of the work here is done in the UnwrappedLineParser, which should skip 
over comments anyway. So yes, we should allow for these comments, but I don't 
think the logic needs to get much more complex because of that. I strongly 
doubt that a state machine is the right mechanism here.

And generally (without specific action to derive from that), I think we should 
try to err on the side of incorrectly finding header guards instead of 
incorrectly not recognizing a header guard. I think a not-indented #define 
somewhere is better than an incorrectly indented header guard.


https://reviews.llvm.org/D35955



___
cfe-commits mailing list

[PATCH] D36664: [analyzer] Make StmtDataCollector customizable

2017-08-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

In https://reviews.llvm.org/D36664#841758, @teemperor wrote:

> Very well done, I really like this patch! I added a few remarks mostly about 
> the comments that need some small adjusting.
>
> I'm wondering what would be a nice way of creating a StmtDataCollector that 
> is faster but only works for single translation units (e.g. it only hashes 
> the pointer values of decls instead of their qualified name)? The use case 
> here would be Stmt::Profile and the CloneDetector which could be set to a 
> single-TU-mode in the CloneChecker. For Stmt::Profile it would ensure we 
> don't degrade performance from the current version, for the CloneChecker we 
> probably get a reasonable performance boost (as the hashing is currently the 
> last remaining bottle neck).
>
> @arphaman Any suggestions who could review/approve the additions to `AST/`?


So we want at least two different modes

- unstable / hash pointer members
- stable / follow pointer members

We can do this by using two macros with different names. So we can split 
`DEF_ADD_DATA` in something like `COLLECT_DATA_STABLE` and 
`COLLECT_DATA_UNSTABLE`
Both would share the collection of POD members, so it makes sense to use a 
third macro for this.

So the code in StmtDataCollectors.inc assumes that DataCollection.h has been 
included, and that there is a `addData()` function as well as an `ASTContext 
` in the current scope.
These things should be documented in DataCollection.h I guess.

Since `StmtDataCollectors.inc` resides in `lib` I have to use relative paths 
(so the include directive looks different depending on the current file), we 
have to live with this, right?


https://reviews.llvm.org/D36664



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


[PATCH] D36664: [analyzer] Make StmtDataCollector customizable

2017-08-16 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 111317.
johannes added a subscriber: rsmith.
johannes added a comment.

add


https://reviews.llvm.org/D36664

Files:
  include/clang/AST/DataCollection.h
  include/clang/Analysis/CloneDetection.h
  lib/AST/CMakeLists.txt
  lib/AST/DataCollection.cpp
  lib/AST/StmtDataCollectors.inc
  lib/Analysis/CloneDetection.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/DataCollectionTest.cpp

Index: unittests/AST/DataCollectionTest.cpp
===
--- /dev/null
+++ unittests/AST/DataCollectionTest.cpp
@@ -0,0 +1,173 @@
+//===- unittests/AST/DataCollectionTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the DataCollection module.
+//
+// They work by hashing the collected data of two nodes and asserting that the
+// hash values are equal iff the nodes are considered equal.
+//
+//===--===//
+
+#include "clang/AST/DataCollection.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+class StmtDataCollector : public ConstStmtVisitor {
+  ASTContext 
+  llvm::MD5 
+
+  template  void addData(const T ) {
+data_collection::addDataToConsumer(DataConsumer, Data);
+  }
+
+public:
+  StmtDataCollector(const Stmt *S, ASTContext , llvm::MD5 )
+  : Context(Context), DataConsumer(DataConsumer) {
+this->Visit(S);
+  }
+
+#define DEF_ADD_DATA(CLASS, CODE)  \
+  template  Dummy Visit##CLASS(const CLASS *S) {   \
+CODE;  \
+ConstStmtVisitor::Visit##CLASS(S);  \
+  }
+
+#include "../../lib/AST/StmtDataCollectors.inc"
+};
+} // end anonymous namespace
+
+namespace {
+struct StmtHashMatch : public MatchFinder::MatchCallback {
+  unsigned NumFound;
+  llvm::MD5::MD5Result 
+  StmtHashMatch(llvm::MD5::MD5Result ) : NumFound(0), Hash(Hash) {}
+
+  void run(const MatchFinder::MatchResult ) override {
+const Stmt *S = Result.Nodes.getNodeAs("id");
+if (!S)
+  return;
+++NumFound;
+if (NumFound > 1)
+  return;
+llvm::MD5 MD5;
+StmtDataCollector(S, *Result.Context, MD5);
+MD5.final(Hash);
+  }
+};
+} // end anonymous namespace
+
+static testing::AssertionResult hashStmt(llvm::MD5::MD5Result ,
+ const StatementMatcher ,
+ StringRef Code) {
+  StmtHashMatch Hasher(Hash);
+  MatchFinder Finder;
+  Finder.addMatcher(StmtMatch, );
+  std::unique_ptr Factory(
+  newFrontendActionFactory());
+  if (!runToolOnCode(Factory->create(), Code))
+return testing::AssertionFailure()
+   << "Parsing error in \"" << Code.str() << "\"";
+  if (Hasher.NumFound == 0)
+return testing::AssertionFailure() << "Matcher didn't find any statements";
+  if (Hasher.NumFound > 1)
+return testing::AssertionFailure()
+   << "Matcher should match only one statement "
+  "(found "
+   << Hasher.NumFound << ")";
+  return testing::AssertionSuccess();
+}
+
+static testing::AssertionResult
+isStmtHashEqual(const StatementMatcher , StringRef Code1,
+StringRef Code2) {
+  llvm::MD5::MD5Result Hash1, Hash2;
+  testing::AssertionResult Result = hashStmt(Hash1, StmtMatch, Code1);
+  if (!Result)
+return Result;
+  if (!(Result = hashStmt(Hash2, StmtMatch, Code2)))
+return Result;
+
+  return testing::AssertionResult(Hash1 == Hash2);
+}
+
+TEST(StmtDataCollector, TestDeclRefExpr) {
+  ASSERT_TRUE(isStmtHashEqual(declRefExpr().bind("id"), "int x, r = x;",
+  "int x, r = x;"));
+  ASSERT_FALSE(isStmtHashEqual(declRefExpr().bind("id"), "int x, r = x;",
+   "int y, r = y;"));
+  ASSERT_FALSE(isStmtHashEqual(declRefExpr().bind("id"), "int x, r = x;",
+   "namespace n { int x, r = x; };"));
+}
+
+TEST(StmtDataCollector, TestMemberExpr) {
+  ASSERT_TRUE(isStmtHashEqual(memberExpr().bind("id"),
+  "struct { int x; } X; int r = X.x;",
+  "struct { int x; } X; int r = ()->x;"));
+  ASSERT_TRUE(isStmtHashEqual(memberExpr().bind("id"),
+  "struct { int x; } X; int r = X.x;",
+  "struct { int x; } Y; int r = Y.x;"));
+  ASSERT_TRUE(isStmtHashEqual(memberExpr().bind("id"),
+  

  1   2   >