[clang-tools-extra] r236405 - Update to match clang r236404.
Richard Smith
richard-llvm at metafoo.co.uk
Sun May 3 20:15:55 PDT 2015
Author: rsmith
Date: Sun May 3 22:15:55 2015
New Revision: 236405
URL: http://llvm.org/viewvc/llvm-project?rev=236405&view=rev
Log:
Update to match clang r236404.
Modified:
clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp
clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp
Modified: clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp Sun May 3 22:15:55 2015
@@ -144,17 +144,15 @@ private:
}
void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
- const MacroDirective *MD) override {
+ const MacroDefinition &MD) override {
Guard->Count++;
// If this #ifndef is the top-most directive and the symbol isn't defined
// store those information in the guard detection, the next step will be to
// check for the define.
- if (Guard->Count == 1 && MD == nullptr) {
+ if (Guard->Count == 1 && !MD) {
IdentifierInfo *MII = MacroNameTok.getIdentifierInfo();
- if (MII->hasMacroDefinition())
- return;
Guard->IfndefLoc = Loc;
Guard->TheMacro = MII;
}
@@ -196,14 +194,14 @@ private:
Guard->EndifLoc = Loc;
}
- void MacroExpands(const Token &, const MacroDirective *, SourceRange,
+ void MacroExpands(const Token &, const MacroDefinition &, SourceRange,
const MacroArgs *) override {
Guard->Count++;
}
- void MacroUndefined(const Token &, const MacroDirective *) override {
+ void MacroUndefined(const Token &, const MacroDefinition &) override {
Guard->Count++;
}
- void Defined(const Token &, const MacroDirective *, SourceRange) override {
+ void Defined(const Token &, const MacroDefinition &, SourceRange) override {
Guard->Count++;
}
void If(SourceLocation, SourceRange, ConditionValueKind) override {
@@ -213,7 +211,7 @@ private:
SourceLocation) override {
Guard->Count++;
}
- void Ifdef(SourceLocation, const Token &, const MacroDirective *) override {
+ void Ifdef(SourceLocation, const Token &, const MacroDefinition &) override {
Guard->Count++;
}
void Else(SourceLocation, SourceLocation) override {
Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Sun May 3 22:15:55 2015
@@ -58,7 +58,7 @@ public:
}
void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
- const MacroDirective *MD) override {
+ const MacroDefinition &MD) override {
if (MD)
return;
@@ -71,7 +71,7 @@ public:
const MacroDirective *MD) override {
// Record all defined macros. We store the whole token to get info on the
// name later.
- Macros.emplace_back(MacroNameTok, MD);
+ Macros.emplace_back(MacroNameTok, MD->getMacroInfo());
}
void Endif(SourceLocation Loc, SourceLocation IfLoc) override {
@@ -84,7 +84,7 @@ public:
SourceManager &SM = PP->getSourceManager();
for (const auto &MacroEntry : Macros) {
- const MacroInfo *MI = MacroEntry.second->getMacroInfo();
+ const MacroInfo *MI = MacroEntry.second;
// We use clang's header guard detection. This has the advantage of also
// emitting a warning for cases where a pseudo header guard is found but
@@ -268,7 +268,7 @@ public:
}
private:
- std::vector<std::pair<Token, const MacroDirective *>> Macros;
+ std::vector<std::pair<Token, const MacroInfo *>> Macros;
llvm::StringMap<const FileEntry *> Files;
std::map<const IdentifierInfo *, std::pair<SourceLocation, SourceLocation>>
Ifndefs;
Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Sun May 3 22:15:55 2015
@@ -763,10 +763,10 @@ public:
clang::SrcMgr::CharacteristicKind FileType,
clang::FileID PrevFID = clang::FileID()) override;
void MacroExpands(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD, clang::SourceRange Range,
+ const clang::MacroDefinition &MD, clang::SourceRange Range,
const clang::MacroArgs *Args) override;
void Defined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD,
+ const clang::MacroDefinition &MD,
clang::SourceRange Range) override;
void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange,
clang::PPCallbacks::ConditionValueKind ConditionResult) override;
@@ -774,9 +774,9 @@ public:
clang::PPCallbacks::ConditionValueKind ConditionResult,
clang::SourceLocation IfLoc) override;
void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) override;
+ const clang::MacroDefinition &MD) override;
void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) override;
+ const clang::MacroDefinition &MD) override;
private:
PreprocessorTrackerImpl &PPTracker;
@@ -1336,7 +1336,7 @@ void PreprocessorCallbacks::FileChanged(
// Handle macro expansion.
void PreprocessorCallbacks::MacroExpands(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD,
+ const clang::MacroDefinition &MD,
clang::SourceRange Range,
const clang::MacroArgs *Args) {
clang::SourceLocation Loc = Range.getBegin();
@@ -1344,7 +1344,7 @@ void PreprocessorCallbacks::MacroExpands
if (!Loc.isFileID())
return;
clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
- const clang::MacroInfo *MI = PP.getMacroInfo(II);
+ const clang::MacroInfo *MI = MD.getMacroInfo();
std::string MacroName = II->getName().str();
std::string Unexpanded(getMacroUnexpandedString(Range, PP, MacroName, MI));
std::string Expanded(getMacroExpandedString(PP, MacroName, MI, Args));
@@ -1354,11 +1354,11 @@ void PreprocessorCallbacks::MacroExpands
}
void PreprocessorCallbacks::Defined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD,
+ const clang::MacroDefinition &MD,
clang::SourceRange Range) {
clang::SourceLocation Loc(Range.getBegin());
clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
- const clang::MacroInfo *MI = PP.getMacroInfo(II);
+ const clang::MacroInfo *MI = MD.getMacroInfo();
std::string MacroName = II->getName().str();
std::string Unexpanded(getSourceString(PP, Range));
PPTracker.addMacroExpansionInstance(
@@ -1388,7 +1388,7 @@ void PreprocessorCallbacks::Elif(clang::
void PreprocessorCallbacks::Ifdef(clang::SourceLocation Loc,
const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) {
+ const clang::MacroDefinition &MD) {
clang::PPCallbacks::ConditionValueKind IsDefined =
(MD ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
PPTracker.addConditionalExpansionInstance(
@@ -1399,7 +1399,7 @@ void PreprocessorCallbacks::Ifdef(clang:
void PreprocessorCallbacks::Ifndef(clang::SourceLocation Loc,
const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) {
+ const clang::MacroDefinition &MD) {
clang::PPCallbacks::ConditionValueKind IsNotDefined =
(!MD ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
PPTracker.addConditionalExpansionInstance(
Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Sun May 3 22:15:55 2015
@@ -302,12 +302,12 @@ void PPCallbacksTracker::PragmaWarningPo
// macro invocation is found.
void
PPCallbacksTracker::MacroExpands(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective,
+ const clang::MacroDefinition &MacroDefinition,
clang::SourceRange Range,
const clang::MacroArgs *Args) {
beginCallback("MacroExpands");
appendArgument("MacroNameTok", MacroNameTok);
- appendArgument("MacroDirective", MacroDirective);
+ appendArgument("MacroDefinition", MacroDefinition);
appendArgument("Range", Range);
appendArgument("Args", Args);
}
@@ -324,19 +324,19 @@ PPCallbacksTracker::MacroDefined(const c
// Hook called whenever a macro #undef is seen.
void PPCallbacksTracker::MacroUndefined(
const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective) {
+ const clang::MacroDefinition &MacroDefinition) {
beginCallback("MacroUndefined");
appendArgument("MacroNameTok", MacroNameTok);
- appendArgument("MacroDirective", MacroDirective);
+ appendArgument("MacroDefinition", MacroDefinition);
}
// Hook called whenever the 'defined' operator is seen.
void PPCallbacksTracker::Defined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective,
+ const clang::MacroDefinition &MacroDefinition,
clang::SourceRange Range) {
beginCallback("Defined");
appendArgument("MacroNameTok", MacroNameTok);
- appendArgument("MacroDirective", MacroDirective);
+ appendArgument("MacroDefinition", MacroDefinition);
appendArgument("Range", Range);
}
@@ -371,21 +371,21 @@ void PPCallbacksTracker::Elif(clang::Sou
// Hook called whenever an #ifdef is seen.
void PPCallbacksTracker::Ifdef(clang::SourceLocation Loc,
const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective) {
+ const clang::MacroDefinition &MacroDefinition) {
beginCallback("Ifdef");
appendArgument("Loc", Loc);
appendArgument("MacroNameTok", MacroNameTok);
- appendArgument("MacroDirective", MacroDirective);
+ appendArgument("MacroDefinition", MacroDefinition);
}
// Hook called whenever an #ifndef is seen.
void PPCallbacksTracker::Ifndef(clang::SourceLocation Loc,
const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective) {
+ const clang::MacroDefinition &MacroDefinition) {
beginCallback("Ifndef");
appendArgument("Loc", Loc);
appendArgument("MacroNameTok", MacroNameTok);
- appendArgument("MacroDirective", MacroDirective);
+ appendArgument("MacroDefinition", MacroDefinition);
}
// Hook called whenever an #else is seen.
@@ -558,6 +558,25 @@ void PPCallbacksTracker::appendArgument(
appendArgument(Name, MacroDirectiveKindStrings[Value->getKind()]);
}
+// Append a MacroDefinition argument to the top trace item.
+void PPCallbacksTracker::appendArgument(const char *Name,
+ const clang::MacroDefinition &Value) {
+ std::string Str;
+ llvm::raw_string_ostream SS(Str);
+ SS << "[";
+ bool Any = false;
+ if (Value.getLocalDirective()) {
+ SS << "(local)";
+ Any = true;
+ }
+ for (auto *MM : Value.getModuleMacros()) {
+ if (Any) SS << ", ";
+ SS << MM->getOwningModule()->getFullModuleName();
+ }
+ SS << "]";
+ appendArgument(Name, SS.str());
+}
+
// Append a MacroArgs argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
const clang::MacroArgs *Value) {
Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Sun May 3 22:15:55 2015
@@ -129,14 +129,14 @@ public:
void PragmaWarningPush(clang::SourceLocation Loc, int Level) override;
void PragmaWarningPop(clang::SourceLocation Loc) override;
void MacroExpands(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD, clang::SourceRange Range,
+ const clang::MacroDefinition &MD, clang::SourceRange Range,
const clang::MacroArgs *Args) override;
void MacroDefined(const clang::Token &MacroNameTok,
const clang::MacroDirective *MD) override;
void MacroUndefined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) override;
+ const clang::MacroDefinition &MD) override;
void Defined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD,
+ const clang::MacroDefinition &MD,
clang::SourceRange Range) override;
void SourceRangeSkipped(clang::SourceRange Range) override;
void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange,
@@ -144,9 +144,9 @@ public:
void Elif(clang::SourceLocation Loc, clang::SourceRange ConditionRange,
ConditionValueKind ConditionValue, clang::SourceLocation IfLoc) override;
void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) override;
+ const clang::MacroDefinition &MD) override;
void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok,
- const clang::MacroDirective *MD) override;
+ const clang::MacroDefinition &MD) override;
void Else(clang::SourceLocation Loc,
clang::SourceLocation IfLoc) override;
void Endif(clang::SourceLocation Loc,
@@ -205,6 +205,9 @@ public:
/// \brief Append a MacroDirective argument to the top trace item.
void appendArgument(const char *Name, const clang::MacroDirective *Value);
+ /// \brief Append a MacroDefinition argument to the top trace item.
+ void appendArgument(const char *Name, const clang::MacroDefinition &Value);
+
/// \brief Append a MacroArgs argument to the top trace item.
void appendArgument(const char *Name, const clang::MacroArgs *Value);
Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-conditional.cpp Sun May 3 22:15:55 2015
@@ -271,14 +271,14 @@
// CHECK-NEXT: - Callback: Ifdef
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:55:2"
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: - Callback: Endif
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:56:2"
// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:55:2"
// CHECK-NEXT: - Callback: Ifdef
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:57:2"
// CHECK-NEXT: MacroNameTok: NO_MACRO
-// CHECK-NEXT: MacroDirective: (null)
+// CHECK-NEXT: MacroDefinition: []
// CHECK-NEXT: - Callback: Endif
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:58:2"
// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:57:2"
@@ -287,7 +287,7 @@
// CHECK-NEXT: - Callback: Ifndef
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:59:2"
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: - Callback: Endif
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:60:2"
// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:59:2"
@@ -296,7 +296,7 @@
// CHECK-NEXT: - Callback: Ifndef
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:61:2"
// CHECK-NEXT: MacroNameTok: NO_MACRO
-// CHECK-NEXT: MacroDirective: (null)
+// CHECK-NEXT: MacroDefinition: []
// CHECK-NEXT: - Callback: Endif
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:62:2"
// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:61:2"
Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp?rev=236405&r1=236404&r2=236405&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-macro.cpp Sun May 3 22:15:55 2015
@@ -35,12 +35,12 @@ X
// CHECK-NEXT: MacroDirective: MD_Define
// CHECK-NEXT: - Callback: MacroExpands
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:4:9", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:4:9"]
// CHECK-NEXT: Args: (null)
// CHECK-NEXT: - Callback: Defined
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:19"]
// CHECK-NEXT: - Callback: If
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:2"
@@ -51,10 +51,10 @@ X
// CHECK-NEXT: IfLoc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:5:2"
// CHECK-NEXT: - Callback: MacroUndefined
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: - Callback: Defined
// CHECK-NEXT: MacroNameTok: MACRO
-// CHECK-NEXT: MacroDirective: (null)
+// CHECK-NEXT: MacroDefinition: []
// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:5", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:19"]
// CHECK-NEXT: - Callback: If
// CHECK-NEXT: Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:2"
@@ -70,7 +70,7 @@ X
// CHECK-NEXT: MacroDirective: MD_Define
// CHECK-NEXT: - Callback: MacroExpands
// CHECK-NEXT: MacroNameTok: FUNCMACRO
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:11:9", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:11:20"]
// CHECK-NEXT: Args: [1]
// CHECK-NEXT: - Callback: MacroDefined
@@ -84,17 +84,17 @@ X
// CHECK-NEXT: MacroDirective: MD_Define
// CHECK-NEXT: - Callback: MacroExpands
// CHECK-NEXT: MacroNameTok: X
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:15:1", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:15:1"]
// CHECK-NEXT: Args: (null)
// CHECK-NEXT: - Callback: MacroExpands
// CHECK-NEXT: MacroNameTok: X_IMPL
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: [(nonfile), (nonfile)]
// CHECK-NEXT: Args: [a <plus> y, b]
// CHECK-NEXT: - Callback: MacroExpands
// CHECK-NEXT: MacroNameTok: X_IMPL2
-// CHECK-NEXT: MacroDirective: MD_Define
+// CHECK-NEXT: MacroDefinition: [(local)]
// CHECK-NEXT: Range: [(nonfile), (nonfile)]
// CHECK-NEXT: Args: [c]
// CHECK-NEXT: - Callback: EndOfMainFile
More information about the cfe-commits
mailing list