<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I don’t have a reduced test case.</div><br class=""><div><blockquote type="cite" class=""><div class="">On May 4, 2015, at 12:50 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks, do you have a testcase that you could check in? The fix would be:<div class=""><pre style="" class="">Index: lib/Serialization/ASTReader.cpp
===================================================================
--- lib/Serialization/ASTReader.cpp (revision 236400)
+++ lib/Serialization/ASTReader.cpp (working copy)
@@ -1829,7 +1829,8 @@
Earliest = MD;
}
- PP.setLoadedMacroDirective(II, Latest);
+ if (Latest)
+ PP.setLoadedMacroDirective(II, Latest);
}
ASTReader::InputFileInfo</pre></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, May 4, 2015 at 12:44 PM, Argyrios Kyrtzidis <span dir="ltr" class=""><<a href="mailto:kyrtzidis@apple.com" target="_blank" class="">kyrtzidis@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Thanks Richard!</div><div class=""><br class=""></div><div class="">There is another crash where a MacroDirective pointer is null, but unfortunately I don’t have a small test case, here’s how to reproduce on OSX:</div><div class="">It seems to crash when indexing the CoreFoundation pcm file.</div><div class=""><br class=""></div><div class="">$ cat /tmp/t.m<br class="">@import CoreFoundation;<br class=""><br class=""></div><div class="">$ env LIBCLANG_DISABLE_CRASH_RECOVERY=1 /path/to/Debug/bin/c-index-test -index-file-full -fmodules -fmodules-cache-path=/tmp/mcp /tmp/t.m<br class="">[enteredMainFile]: /tmp/t.m<br class="">[startedTranslationUnit]<br class="">[importedASTFile]: /tmp/mcp/LR9RPFKHW5SM/CoreFoundation-VHR5HL056G2W.pcm | loc: 1:1 | name: "CoreFoundation" | isImplicit: 0<br class="">[startedTranslationUnit]<br class="">Assertion failed: (II && MD), function setLoadedMacroDirective, file src/tools/clang/lib/Lex/PPMacroExpansion.cpp, line 64.<br class="">0 libclang.3.6.dylib 0x000000010cda4e5e llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46<br class="">1 libclang.3.6.dylib 0x000000010cda6709 PrintStackTraceSignalHandler(void*) + 25<br class="">2 libclang.3.6.dylib 0x000000010cda6afe SignalHandler(int) + 526<br class="">3 libsystem_platform.dylib 0x00007fff8dcb0f1a _sigtramp + 26<br class="">4 libsystem_platform.dylib 0x6e696c202c707063 _sigtramp + 2661638499<br class="">5 libclang.3.6.dylib 0x000000010cda672b raise + 27<br class="">6 libclang.3.6.dylib 0x000000010cda67e2 abort + 18<br class="">7 libclang.3.6.dylib 0x000000010cda67c1 __assert_rtn + 129<br class="">8 libclang.3.6.dylib 0x000000010ba47d1f clang::Preprocessor::setLoadedMacroDirective(clang::IdentifierInfo*, clang::MacroDirective*) + 127<br class="">9 libclang.3.6.dylib 0x000000010d02e948 clang::ASTReader::resolvePendingMacro(clang::IdentifierInfo*, clang::ASTReader::PendingMacroInfo const&) + 2648<br class="">10 libclang.3.6.dylib 0x000000010d06125a clang::ASTReader::finishPendingActions() + 1786<br class="">11 libclang.3.6.dylib 0x000000010d062c02 clang::ASTReader::FinishedDeserializing() + 178<br class="">12 libclang.3.6.dylib 0x000000010d062ebc non-virtual thunk to clang::ASTReader::FinishedDeserializing() + 28<br class="">13 libclang.3.6.dylib 0x000000010b4e031c clang::ExternalASTSource::Deserializing::~Deserializing() + 28<br class="">14 libclang.3.6.dylib 0x000000010b4dc685 clang::ExternalASTSource::Deserializing::~Deserializing() + 21<br class="">15 libclang.3.6.dylib 0x000000010d05cfc6 clang::ASTReader::get(char const*, char const*) + 486<br class="">16 libclang.3.6.dylib 0x000000010d076df4 clang::ASTReader::get(llvm::StringRef) + 84<br class="">17 libclang.3.6.dylib 0x000000010d076f97 non-virtual thunk to clang::ASTReader::get(llvm::StringRef) + 55<br class="">18 libclang.3.6.dylib 0x000000010b213a0c clang::IdentifierTable::get(llvm::StringRef) + 572<br class="">19 libclang.3.6.dylib 0x000000010d05ea32 clang::ASTReader::DecodeIdentifierInfo(unsigned int) + 578<br class="">20 libclang.3.6.dylib 0x000000010d026020 clang::ASTReader::getLocalIdentifier(clang::serialization::ModuleFile&, unsigned int) + 64<br class="">21 libclang.3.6.dylib 0x000000010d04f501 clang::ASTReader::ReadPreprocessedEntity(unsigned int) + 1297<br class="">22 libclang.3.6.dylib 0x000000010d04f952 non-virtual thunk to clang::ASTReader::ReadPreprocessedEntity(unsigned int) + 34<br class="">23 libclang.3.6.dylib 0x000000010ba7220d clang::PreprocessingRecord::getLoadedPreprocessedEntity(unsigned int) + 317<br class="">24 libclang.3.6.dylib 0x000000010ba73c15 clang::PreprocessingRecord::getPreprocessedEntity(clang::PreprocessingRecord::PPEntityID) + 181<br class="">25 libclang.3.6.dylib 0x000000010b23662f clang::PreprocessingRecord::iterator::operator*() const + 159<br class="">26 libclang.3.6.dylib 0x000000010b313323 indexPreprocessingRecord(clang::ASTUnit&, clang::cxindex::IndexingContext&) + 163<br class="">27 libclang.3.6.dylib 0x000000010b30daa1 clang_indexTranslationUnit_Impl(void*) + 2289<br class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 3, 2015, at 8:20 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank" class="">richard@metafoo.co.uk</a>> wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, May 2, 2015 at 7:43 PM, Argyrios Kyrtzidis<span class=""> </span><span dir="ltr" class=""><<a href="mailto:kyrtzidis@apple.com" target="_blank" class="">kyrtzidis@apple.com</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Richard,<br class=""><br class="">This commit crashes the preprocessing record (and in general PPCallbacks clients). To reproduce the crash try this change:<br class=""><br class="">diff --git a/test/Modules/macros.c b/test/Modules/macros.c<br class="">index 0761669..d2dc326 100644<br class="">--- a/test/Modules/macros.c<br class="">+++ b/test/Modules/macros.c<br class="">@@ -1,5 +1,5 @@<br class=""> // RUN: rm -rf %t<br class="">-// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s<br class="">+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s -detailed-preprocessing-record<br class=""> // RUN: %clang_cc1 -fmodules -DLOCAL_VISIBILITY -fmodules-local-submodule-visibility -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s<br class=""> // RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s<br class=""> // FIXME: When we have a syntax for modules in C, use that.<br class=""><br class="">Could you take a look ?</blockquote><div class=""><br class=""></div><div class="">Thanks, should be fixed in r<span class="">236404; the PPCallbacks clients are now given the full macro information. This is an API change for PPCallbacks consumers, though.</span></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="">> On Apr 29, 2015, at 4:20 PM, Richard Smith <<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank" class="">richard-llvm@metafoo.co.uk</a>> wrote:<br class="">><br class="">> Author: rsmith<br class="">> Date: Wed Apr 29 18:20:19 2015<br class="">> New Revision: 236176<br class="">><br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project?rev=236176&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=236176&view=rev</a><br class="">> Log:<br class="">> [modules] Stop trying to fake up a linear MacroDirective history.<br class="">><br class="">> Modules builds fundamentally have a non-linear macro history. In the interest<br class="">> of better source fidelity, represent the macro definition information<br class="">> faithfully: we have a linear macro directive history within each module, and at<br class="">> any point we have a unique "latest" local macro directive and a collection of<br class="">> visible imported directives. This also removes the attendent complexity of<br class="">> attempting to create a correct MacroDirective history (which we got wrong<br class="">> in the general case).<br class="">><br class="">> No functionality change intended.<br class="">><br class="">> Modified:<br class="">> cfe/trunk/include/clang/AST/NSAPI.h<br class="">> cfe/trunk/include/clang/Basic/IdentifierTable.h<br class="">> cfe/trunk/include/clang/Lex/HeaderSearch.h<br class="">> cfe/trunk/include/clang/Lex/Preprocessor.h<br class="">> cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">> cfe/trunk/lib/ARCMigrate/ObjCMT.cpp<br class="">> cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp<br class="">> cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp<br class="">> cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp<br class="">> cfe/trunk/lib/ARCMigrate/Transforms.cpp<br class="">> cfe/trunk/lib/ARCMigrate/Transforms.h<br class="">> cfe/trunk/lib/AST/NSAPI.cpp<br class="">> cfe/trunk/lib/Frontend/CompilerInstance.cpp<br class="">> cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br class="">> cfe/trunk/lib/Lex/HeaderSearch.cpp<br class="">> cfe/trunk/lib/Lex/MacroArgs.cpp<br class="">> cfe/trunk/lib/Lex/PPDirectives.cpp<br class="">> cfe/trunk/lib/Lex/PPExpressions.cpp<br class="">> cfe/trunk/lib/Lex/PPLexerChange.cpp<br class="">> cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br class="">> cfe/trunk/lib/Lex/Pragma.cpp<br class="">> cfe/trunk/lib/Lex/Preprocessor.cpp<br class="">> cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br class="">> cfe/trunk/lib/Sema/SemaExpr.cpp<br class="">> cfe/trunk/lib/Sema/SemaFixItUtils.cpp<br class="">> cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp<br class="">> cfe/trunk/lib/Serialization/ASTWriter.cpp<br class="">> cfe/trunk/test/Index/complete-macros.c<br class="">> cfe/trunk/test/Modules/macros.c<br class="">> cfe/trunk/tools/libclang/CIndex.cpp<br class="">><br class="">> Modified: cfe/trunk/include/clang/AST/NSAPI.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/NSAPI.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/NSAPI.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/include/clang/AST/NSAPI.h (original)<br class="">> +++ cfe/trunk/include/clang/AST/NSAPI.h Wed Apr 29 18:20:19 2015<br class="">> @@ -216,6 +216,9 @@ public:<br class="">> /// of that name in objective-c.<br class="">> StringRef GetNSIntegralKind(QualType T) const;<br class="">><br class="">> + /// \brief Returns \c true if \p Id is currently defined as a macro.<br class="">> + bool isMacroDefined(StringRef Id) const;<br class="">> +<br class="">> private:<br class="">> bool isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const;<br class="">> bool isObjCEnumerator(const Expr *E,<br class="">><br class="">> Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)<br class="">> +++ cfe/trunk/include/clang/Basic/IdentifierTable.h Wed Apr 29 18:20:19 2015<br class="">> @@ -124,6 +124,7 @@ public:<br class="">> }<br class="">><br class="">> /// \brief Return true if this identifier is \#defined to some other value.<br class="">> + /// \note The current definition may be in a module and not currently visible.<br class="">> bool hasMacroDefinition() const {<br class="">> return HasMacro;<br class="">> }<br class="">><br class="">> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)<br class="">> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Apr 29 18:20:19 2015<br class="">> @@ -32,6 +32,7 @@ class FileEntry;<br class="">> class FileManager;<br class="">> class HeaderSearchOptions;<br class="">> class IdentifierInfo;<br class="">> +class Preprocessor;<br class="">><br class="">> /// \brief The preprocessor keeps track of this information for each<br class="">> /// file that is \#included.<br class="">> @@ -419,8 +420,8 @@ public:<br class="">> ///<br class="">> /// \return false if \#including the file will have no effect or true<br class="">> /// if we should include it.<br class="">> - bool ShouldEnterIncludeFile(const FileEntry *File, bool isImport);<br class="">> -<br class="">> + bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,<br class="">> + bool isImport);<br class="">><br class="">> /// \brief Return whether the specified file is a normal header,<br class="">> /// a system header, or a C++ friendly system header.<br class="">><br class="">> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)<br class="">> +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Apr 29 18:20:19 2015<br class="">> @@ -386,7 +386,8 @@ class Preprocessor : public RefCountedBa<br class="">> class MacroState {<br class="">> mutable llvm::PointerUnion<MacroDirective *, ModuleMacroInfo *> State;<br class="">><br class="">> - ModuleMacroInfo *getModuleInfo(Preprocessor &PP, IdentifierInfo *II) const {<br class="">> + ModuleMacroInfo *getModuleInfo(Preprocessor &PP,<br class="">> + const IdentifierInfo *II) const {<br class="">> // FIXME: Find a spare bit on IdentifierInfo and store a<br class="">> // HasModuleMacros flag.<br class="">> if (!II->hasMacroDefinition() || !PP.getLangOpts().Modules ||<br class="">> @@ -434,12 +435,12 @@ class Preprocessor : public RefCountedBa<br class="">> State = MD;<br class="">> }<br class="">><br class="">> - bool isAmbiguous(Preprocessor &PP, IdentifierInfo *II) const {<br class="">> + bool isAmbiguous(Preprocessor &PP, const IdentifierInfo *II) const {<br class="">> auto *Info = getModuleInfo(PP, II);<br class="">> return Info ? Info->IsAmbiguous : false;<br class="">> }<br class="">> - ArrayRef<ModuleMacro *> getActiveModuleMacros(Preprocessor &PP,<br class="">> - IdentifierInfo *II) const {<br class="">> + ArrayRef<ModuleMacro *><br class="">> + getActiveModuleMacros(Preprocessor &PP, const IdentifierInfo *II) const {<br class="">> if (auto *Info = getModuleInfo(PP, II))<br class="">> return Info->ActiveModuleMacros;<br class="">> return None;<br class="">> @@ -755,33 +756,119 @@ public:<br class="">> }<br class="">> /// \}<br class="">><br class="">> - /// \brief Given an identifier, return its latest MacroDirective if it is<br class="">> - /// \#defined or null if it isn't \#define'd.<br class="">> - MacroDirective *getMacroDirective(IdentifierInfo *II) const {<br class="">> + /// \brief A description of the current definition of a macro.<br class="">> + class MacroDefinition {<br class="">> + llvm::PointerIntPair<DefMacroDirective*, 1, bool> LatestLocalAndAmbiguous;<br class="">> + ArrayRef<ModuleMacro*> ModuleMacros;<br class="">> + public:<br class="">> + MacroDefinition() : LatestLocalAndAmbiguous(), ModuleMacros() {}<br class="">> + MacroDefinition(DefMacroDirective *MD, ArrayRef<ModuleMacro *> MMs,<br class="">> + bool IsAmbiguous)<br class="">> + : LatestLocalAndAmbiguous(MD, IsAmbiguous), ModuleMacros(MMs) {}<br class="">> +<br class="">> + /// \brief Determine whether there is a definition of this macro.<br class="">> + explicit operator bool() const {<br class="">> + return getLocalDirective() || !ModuleMacros.empty();<br class="">> + }<br class="">> +<br class="">> + /// \brief Get the MacroInfo that should be used for this definition.<br class="">> + MacroInfo *getMacroInfo() const {<br class="">> + if (!ModuleMacros.empty())<br class="">> + return ModuleMacros.back()->getMacroInfo();<br class="">> + if (auto *MD = getLocalDirective())<br class="">> + return MD->getMacroInfo();<br class="">> + return nullptr;<br class="">> + }<br class="">> +<br class="">> + /// \brief \c true if the definition is ambiguous, \c false otherwise.<br class="">> + bool isAmbiguous() const { return LatestLocalAndAmbiguous.getInt(); }<br class="">> +<br class="">> + /// \brief Get the latest non-imported, non-\#undef'd macro definition<br class="">> + /// for this macro.<br class="">> + DefMacroDirective *getLocalDirective() const {<br class="">> + return LatestLocalAndAmbiguous.getPointer();<br class="">> + }<br class="">> +<br class="">> + /// \brief Get the active module macros for this macro.<br class="">> + ArrayRef<ModuleMacro *> getModuleMacros() const {<br class="">> + return ModuleMacros;<br class="">> + }<br class="">> +<br class="">> + template<typename Fn> void forAllDefinitions(Fn F) const {<br class="">> + if (auto *MD = getLocalDirective())<br class="">> + F(MD->getMacroInfo());<br class="">> + for (auto *MM : getModuleMacros())<br class="">> + F(MM->getMacroInfo());<br class="">> + }<br class="">> + };<br class="">> +<br class="">> + bool isMacroDefined(StringRef Id) {<br class="">> + return isMacroDefined(&Identifiers.get(Id));<br class="">> + }<br class="">> + bool isMacroDefined(const IdentifierInfo *II) {<br class="">> + return II->hasMacroDefinition() &&<br class="">> + (!getLangOpts().Modules || (bool)getMacroDefinition(II));<br class="">> + }<br class="">> +<br class="">> + MacroDefinition getMacroDefinition(const IdentifierInfo *II) {<br class="">> if (!II->hasMacroDefinition())<br class="">> + return MacroDefinition();<br class="">> +<br class="">> + MacroState &S = Macros[II];<br class="">> + auto *MD = S.getLatest();<br class="">> + while (MD && isa<VisibilityMacroDirective>(MD))<br class="">> + MD = MD->getPrevious();<br class="">> + return MacroDefinition(dyn_cast_or_null<DefMacroDirective>(MD),<br class="">> + S.getActiveModuleMacros(*this, II),<br class="">> + S.isAmbiguous(*this, II));<br class="">> + }<br class="">> +<br class="">> + MacroDefinition getMacroDefinitionAtLoc(const IdentifierInfo *II,<br class="">> + SourceLocation Loc) {<br class="">> + if (!II->hadMacroDefinition())<br class="">> + return MacroDefinition();<br class="">> +<br class="">> + MacroState &S = Macros[II];<br class="">> + MacroDirective::DefInfo DI;<br class="">> + if (auto *MD = S.getLatest())<br class="">> + DI = MD->findDirectiveAtLoc(Loc, getSourceManager());<br class="">> + // FIXME: Compute the set of active module macros at the specified location.<br class="">> + return MacroDefinition(DI.getDirective(),<br class="">> + S.getActiveModuleMacros(*this, II),<br class="">> + S.isAmbiguous(*this, II));<br class="">> + }<br class="">> +<br class="">> + /// \brief Given an identifier, return its latest non-imported MacroDirective<br class="">> + /// if it is \#define'd and not \#undef'd, or null if it isn't \#define'd.<br class="">> + MacroDirective *getLocalMacroDirective(const IdentifierInfo *II) const {<br class="">> + if (!II->hasMacroDefinition())<br class="">> + return nullptr;<br class="">> +<br class="">> + auto *MD = getLocalMacroDirectiveHistory(II);<br class="">> + if (!MD || MD->getDefinition().isUndefined())<br class="">> return nullptr;<br class="">><br class="">> - MacroDirective *MD = getMacroDirectiveHistory(II);<br class="">> - assert(MD->isDefined() && "Macro is undefined!");<br class="">> return MD;<br class="">> }<br class="">><br class="">> - const MacroInfo *getMacroInfo(IdentifierInfo *II) const {<br class="">> + const MacroInfo *getMacroInfo(const IdentifierInfo *II) const {<br class="">> return const_cast<Preprocessor*>(this)->getMacroInfo(II);<br class="">> }<br class="">><br class="">> - MacroInfo *getMacroInfo(IdentifierInfo *II) {<br class="">> - if (MacroDirective *MD = getMacroDirective(II))<br class="">> - return MD->getMacroInfo();<br class="">> + MacroInfo *getMacroInfo(const IdentifierInfo *II) {<br class="">> + if (!II->hasMacroDefinition())<br class="">> + return nullptr;<br class="">> + if (auto MD = getMacroDefinition(II))<br class="">> + return MD.getMacroInfo();<br class="">> return nullptr;<br class="">> }<br class="">><br class="">> - /// \brief Given an identifier, return the (probably #undef'd) MacroInfo<br class="">> - /// representing the most recent macro definition.<br class="">> + /// \brief Given an identifier, return the latest non-imported macro<br class="">> + /// directive for that identifier.<br class="">> ///<br class="">> - /// One can iterate over all previous macro definitions from the most recent<br class="">> - /// one. This should only be called for identifiers that hadMacroDefinition().<br class="">> - MacroDirective *getMacroDirectiveHistory(const IdentifierInfo *II) const;<br class="">> + /// One can iterate over all previous macro directives from the most recent<br class="">> + /// one.<br class="">> + MacroDirective *getLocalMacroDirectiveHistory(const IdentifierInfo *II) const;<br class="">><br class="">> /// \brief Add a directive to the macro directive history for this identifier.<br class="">> void appendMacroDirective(IdentifierInfo *II, MacroDirective *MD);<br class="">> @@ -1580,7 +1667,7 @@ private:<br class="">><br class="">> /// Update the set of active module macros and ambiguity flag for a module<br class="">> /// macro name.<br class="">> - void updateModuleMacroInfo(IdentifierInfo *II, ModuleMacroInfo &Info);<br class="">> + void updateModuleMacroInfo(const IdentifierInfo *II, ModuleMacroInfo &Info);<br class="">><br class="">> /// \brief Allocate a new MacroInfo object.<br class="">> MacroInfo *AllocateMacroInfo();<br class="">> @@ -1644,7 +1731,7 @@ private:<br class="">> /// If an identifier token is read that is to be expanded as a macro, handle<br class="">> /// it and return the next token as 'Tok'. If we lexed a token, return true;<br class="">> /// otherwise the caller should lex again.<br class="">> - bool HandleMacroExpandedIdentifier(Token &Tok, MacroDirective *MD);<br class="">> + bool HandleMacroExpandedIdentifier(Token &Tok, const MacroDefinition &MD);<br class="">><br class="">> /// \brief Cache macro expanded tokens for TokenLexers.<br class="">> //<br class="">><br class="">> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br class="">> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Apr 29 18:20:19 2015<br class="">> @@ -576,54 +576,8 @@ private:<br class="">> /// global submodule ID to produce a local ID.<br class="">> GlobalSubmoduleMapType GlobalSubmoduleMap;<br class="">><br class="">> - /// \brief Information on a macro definition or undefinition that is visible<br class="">> - /// at the end of a submodule.<br class="">> - struct ModuleMacroInfo;<br class="">> -<br class="">> - /// \brief An entity that has been hidden.<br class="">> - class HiddenName {<br class="">> - public:<br class="">> - enum NameKind {<br class="">> - Declaration,<br class="">> - Macro<br class="">> - } Kind;<br class="">> -<br class="">> - private:<br class="">> - union {<br class="">> - Decl *D;<br class="">> - ModuleMacroInfo *MMI;<br class="">> - };<br class="">> -<br class="">> - IdentifierInfo *Id;<br class="">> -<br class="">> - public:<br class="">> - HiddenName(Decl *D) : Kind(Declaration), D(D), Id() { }<br class="">> -<br class="">> - HiddenName(IdentifierInfo *II, ModuleMacroInfo *MMI)<br class="">> - : Kind(Macro), MMI(MMI), Id(II) { }<br class="">> -<br class="">> - NameKind getKind() const { return Kind; }<br class="">> -<br class="">> - Decl *getDecl() const {<br class="">> - assert(getKind() == Declaration && "Hidden name is not a declaration");<br class="">> - return D;<br class="">> - }<br class="">> -<br class="">> - std::pair<IdentifierInfo *, ModuleMacroInfo *> getMacro() const {<br class="">> - assert(getKind() == Macro && "Hidden name is not a macro!");<br class="">> - return std::make_pair(Id, MMI);<br class="">> - }<br class="">> - };<br class="">> -<br class="">> - typedef llvm::SmallDenseMap<IdentifierInfo*,<br class="">> - ModuleMacroInfo*> HiddenMacrosMap;<br class="">> -<br class="">> /// \brief A set of hidden declarations.<br class="">> - struct HiddenNames {<br class="">> - SmallVector<Decl*, 2> HiddenDecls;<br class="">> - HiddenMacrosMap HiddenMacros;<br class="">> - };<br class="">> -<br class="">> + typedef SmallVector<Decl*, 2> HiddenNames;<br class="">> typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;<br class="">><br class="">> /// \brief A mapping from each of the hidden submodules to the deserialized<br class="">> @@ -1850,20 +1804,6 @@ public:<br class="">><br class="">> void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);<br class="">><br class="">> - void installImportedMacro(IdentifierInfo *II, ModuleMacroInfo &MMI,<br class="">> - Module *Owner);<br class="">> -<br class="">> - typedef llvm::TinyPtrVector<DefMacroDirective *> AmbiguousMacros;<br class="">> - llvm::DenseMap<IdentifierInfo*, AmbiguousMacros> AmbiguousMacroDefs;<br class="">> -<br class="">> - void removeOverriddenMacros(IdentifierInfo *II, SourceLocation Loc,<br class="">> - AmbiguousMacros &Ambig,<br class="">> - ArrayRef<ModuleMacro *> Overrides);<br class="">> -<br class="">> - AmbiguousMacros *removeOverriddenMacros(IdentifierInfo *II,<br class="">> - SourceLocation Loc,<br class="">> - ArrayRef<ModuleMacro *> Overrides);<br class="">> -<br class="">> /// \brief Retrieve the macro with the given ID.<br class="">> MacroInfo *getMacro(serialization::MacroID ID);<br class="">><br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -468,7 +468,7 @@ static void rewriteToObjCProperty(const<br class="">> ASTContext &Context = NS.getASTContext();<br class="">> bool LParenAdded = false;<br class="">> std::string PropertyString = "@property ";<br class="">> - if (UseNsIosOnlyMacro && Context.Idents.get("NS_NONATOMIC_IOSONLY").hasMacroDefinition()) {<br class="">> + if (UseNsIosOnlyMacro && NS.isMacroDefined("NS_NONATOMIC_IOSONLY")) {<br class="">> PropertyString += "(NS_NONATOMIC_IOSONLY";<br class="">> LParenAdded = true;<br class="">> } else if (!Atomic) {<br class="">> @@ -1277,7 +1277,7 @@ void ObjCMigrateASTConsumer::migrateNsRe<br class="">><br class="">> QualType RT = OM->getReturnType();<br class="">> if (!TypeIsInnerPointer(RT) ||<br class="">> - !Ctx.Idents.get("NS_RETURNS_INNER_POINTER").hasMacroDefinition())<br class="">> + !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))<br class="">> return;<br class="">><br class="">> edit::Commit commit(*Editor);<br class="">> @@ -1288,9 +1288,9 @@ void ObjCMigrateASTConsumer::migrateNsRe<br class="">> void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ctx,<br class="">> ObjCPropertyDecl *P) {<br class="">> QualType T = P->getType();<br class="">> -<br class="">> +<br class="">> if (!TypeIsInnerPointer(T) ||<br class="">> - !Ctx.Idents.get("NS_RETURNS_INNER_POINTER").hasMacroDefinition())<br class="">> + !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))<br class="">> return;<br class="">> edit::Commit commit(*Editor);<br class="">> commit.insertBefore(P->getLocEnd(), " NS_RETURNS_INNER_POINTER ");<br class="">> @@ -1408,7 +1408,7 @@ static bool AuditedType (QualType AT) {<br class="">> void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {<br class="">> if (CFFunctionIBCandidates.empty())<br class="">> return;<br class="">> - if (!Ctx.Idents.get("CF_IMPLICIT_BRIDGING_ENABLED").hasMacroDefinition()) {<br class="">> + if (!NSAPIObj->isMacroDefined("CF_IMPLICIT_BRIDGING_ENABLED")) {<br class="">> CFFunctionIBCandidates.clear();<br class="">> FileId = FileID();<br class="">> return;<br class="">> @@ -1483,16 +1483,14 @@ void ObjCMigrateASTConsumer::AddCFAnnota<br class="">> RetEffect Ret = CE.getReturnValue();<br class="">> const char *AnnotationString = nullptr;<br class="">> if (Ret.getObjKind() == RetEffect::CF) {<br class="">> - if (Ret.isOwned() &&<br class="">> - Ctx.Idents.get("CF_RETURNS_RETAINED").hasMacroDefinition())<br class="">> + if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))<br class="">> AnnotationString = " CF_RETURNS_RETAINED";<br class="">> else if (Ret.notOwned() &&<br class="">> - Ctx.Idents.get("CF_RETURNS_NOT_RETAINED").hasMacroDefinition())<br class="">> + NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))<br class="">> AnnotationString = " CF_RETURNS_NOT_RETAINED";<br class="">> }<br class="">> else if (Ret.getObjKind() == RetEffect::ObjC) {<br class="">> - if (Ret.isOwned() &&<br class="">> - Ctx.Idents.get("NS_RETURNS_RETAINED").hasMacroDefinition())<br class="">> + if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))<br class="">> AnnotationString = " NS_RETURNS_RETAINED";<br class="">> }<br class="">><br class="">> @@ -1509,13 +1507,13 @@ void ObjCMigrateASTConsumer::AddCFAnnota<br class="">> const ParmVarDecl *pd = *pi;<br class="">> ArgEffect AE = AEArgs[i];<br class="">> if (AE == DecRef && !pd->hasAttr<CFConsumedAttr>() &&<br class="">> - Ctx.Idents.get("CF_CONSUMED").hasMacroDefinition()) {<br class="">> + NSAPIObj->isMacroDefined("CF_CONSUMED")) {<br class="">> edit::Commit commit(*Editor);<br class="">> commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");<br class="">> Editor->commit(commit);<br class="">> }<br class="">> else if (AE == DecRefMsg && !pd->hasAttr<NSConsumedAttr>() &&<br class="">> - Ctx.Idents.get("NS_CONSUMED").hasMacroDefinition()) {<br class="">> + NSAPIObj->isMacroDefined("NS_CONSUMED")) {<br class="">> edit::Commit commit(*Editor);<br class="">> commit.insertBefore(pd->getLocation(), "NS_CONSUMED ");<br class="">> Editor->commit(commit);<br class="">> @@ -1600,11 +1598,10 @@ void ObjCMigrateASTConsumer::AddCFAnnota<br class="">> RetEffect Ret = CE.getReturnValue();<br class="">> const char *AnnotationString = nullptr;<br class="">> if (Ret.getObjKind() == RetEffect::CF) {<br class="">> - if (Ret.isOwned() &&<br class="">> - Ctx.Idents.get("CF_RETURNS_RETAINED").hasMacroDefinition())<br class="">> + if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))<br class="">> AnnotationString = " CF_RETURNS_RETAINED";<br class="">> else if (Ret.notOwned() &&<br class="">> - Ctx.Idents.get("CF_RETURNS_NOT_RETAINED").hasMacroDefinition())<br class="">> + NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))<br class="">> AnnotationString = " CF_RETURNS_NOT_RETAINED";<br class="">> }<br class="">> else if (Ret.getObjKind() == RetEffect::ObjC) {<br class="">> @@ -1618,8 +1615,7 @@ void ObjCMigrateASTConsumer::AddCFAnnota<br class="">> break;<br class="">><br class="">> default:<br class="">> - if (Ret.isOwned() &&<br class="">> - Ctx.Idents.get("NS_RETURNS_RETAINED").hasMacroDefinition())<br class="">> + if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))<br class="">> AnnotationString = " NS_RETURNS_RETAINED";<br class="">> break;<br class="">> }<br class="">> @@ -1638,7 +1634,7 @@ void ObjCMigrateASTConsumer::AddCFAnnota<br class="">> const ParmVarDecl *pd = *pi;<br class="">> ArgEffect AE = AEArgs[i];<br class="">> if (AE == DecRef && !pd->hasAttr<CFConsumedAttr>() &&<br class="">> - Ctx.Idents.get("CF_CONSUMED").hasMacroDefinition()) {<br class="">> + NSAPIObj->isMacroDefined("CF_CONSUMED")) {<br class="">> edit::Commit commit(*Editor);<br class="">> commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");<br class="">> Editor->commit(commit);<br class="">> @@ -1658,12 +1654,12 @@ void ObjCMigrateASTConsumer::migrateAddM<br class="">> MethodDecl->hasAttr<NSReturnsRetainedAttr>() ||<br class="">> MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() ||<br class="">> MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>());<br class="">> -<br class="">> - if (CE.getReceiver() == DecRefMsg &&<br class="">> +<br class="">> + if (CE.getReceiver() == DecRefMsg &&<br class="">> !MethodDecl->hasAttr<NSConsumesSelfAttr>() &&<br class="">> MethodDecl->getMethodFamily() != OMF_init &&<br class="">> MethodDecl->getMethodFamily() != OMF_release &&<br class="">> - Ctx.Idents.get("NS_CONSUMES_SELF").hasMacroDefinition()) {<br class="">> + NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) {<br class="">> edit::Commit commit(*Editor);<br class="">> commit.insertBefore(MethodDecl->getLocEnd(), " NS_CONSUMES_SELF");<br class="">> Editor->commit(commit);<br class="">> @@ -1729,7 +1725,7 @@ void ObjCMigrateASTConsumer::inferDesign<br class="">> const ObjCInterfaceDecl *IFace = ImplD->getClassInterface();<br class="">> if (!IFace || IFace->hasDesignatedInitializers())<br class="">> return;<br class="">> - if (!Ctx.Idents.get("NS_DESIGNATED_INITIALIZER").hasMacroDefinition())<br class="">> + if (!NSAPIObj->isMacroDefined("NS_DESIGNATED_INITIALIZER"))<br class="">> return;<br class="">><br class="">> for (const auto *MD : ImplD->instance_methods()) {<br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -95,7 +95,7 @@ public:<br class="">> Pass.TA.clearDiagnostic(diag::err_unavailable,<br class="">> diag::err_unavailable_message,<br class="">> E->getSelectorLoc(0));<br class="">> - Pass.TA.replace(E->getSourceRange(), getNilString(Pass.Ctx));<br class="">> + Pass.TA.replace(E->getSourceRange(), getNilString(Pass));<br class="">> }<br class="">> return true;<br class="">> }<br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -145,7 +145,7 @@ public:<br class="">> // when an exception is thrown.<br class="">> Pass.TA.replace(RecContainer->getSourceRange(), RecRange);<br class="">> std::string str = " = ";<br class="">> - str += getNilString(Pass.Ctx);<br class="">> + str += getNilString(Pass);<br class="">> Pass.TA.insertAfterToken(RecRange.getEnd(), str);<br class="">> return true;<br class="">> }<br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -58,7 +58,7 @@ public:<br class="">> SourceRange ExprRange = ME->getSourceRange();<br class="">> Pass.TA.insert(ExprRange.getBegin(), "if (!(self = ");<br class="">> std::string retStr = ")) return ";<br class="">> - retStr += getNilString(Pass.Ctx);<br class="">> + retStr += getNilString(Pass);<br class="">> Pass.TA.insertAfterToken(ExprRange.getEnd(), retStr);<br class="">> }<br class="">> return true;<br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -16,6 +16,7 @@<br class="">> #include "clang/Basic/SourceManager.h"<br class="">> #include "clang/Basic/TargetInfo.h"<br class="">> #include "clang/Lex/Lexer.h"<br class="">> +#include "clang/Lex/Preprocessor.h"<br class="">> #include "clang/Sema/Sema.h"<br class="">> #include "clang/Sema/SemaDiagnostic.h"<br class="">> #include "llvm/ADT/DenseSet.h"<br class="">> @@ -212,11 +213,8 @@ bool trans::isGlobalVar(Expr *E) {<br class="">> return false;<br class="">> }<br class="">><br class="">> -StringRef trans::getNilString(ASTContext &Ctx) {<br class="">> - if (Ctx.Idents.get("nil").hasMacroDefinition())<br class="">> - return "nil";<br class="">> - else<br class="">> - return "0";<br class="">> +StringRef trans::getNilString(MigrationPass &Pass) {<br class="">> + return Pass.SemaRef.PP.isMacroDefined("nil") ? "nil" : "0";<br class="">> }<br class="">><br class="">> namespace {<br class="">><br class="">> Modified: cfe/trunk/lib/ARCMigrate/Transforms.h<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.h?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.h?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/ARCMigrate/Transforms.h (original)<br class="">> +++ cfe/trunk/lib/ARCMigrate/Transforms.h Wed Apr 29 18:20:19 2015<br class="">> @@ -180,7 +180,7 @@ SourceLocation findSemiAfterLocation(Sou<br class="">> bool hasSideEffects(Expr *E, ASTContext &Ctx);<br class="">> bool isGlobalVar(Expr *E);<br class="">> /// \brief Returns "nil" or "0" if 'nil' macro is not actually defined.<br class="">> -StringRef getNilString(ASTContext &Ctx);<br class="">> +StringRef getNilString(MigrationPass &Pass);<br class="">><br class="">> template <typename BODY_TRANS><br class="">> class BodyTransform : public RecursiveASTVisitor<BodyTransform<BODY_TRANS> > {<br class="">><br class="">> Modified: cfe/trunk/lib/AST/NSAPI.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NSAPI.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NSAPI.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/AST/NSAPI.cpp (original)<br class="">> +++ cfe/trunk/lib/AST/NSAPI.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -505,6 +505,11 @@ StringRef NSAPI::GetNSIntegralKind(QualT<br class="">> return StringRef();<br class="">> }<br class="">><br class="">> +bool NSAPI::isMacroDefined(StringRef Id) const {<br class="">> + // FIXME: Check whether the relevant module macros are visible.<br class="">> + return Ctx.Idents.get(Id).hasMacroDefinition();<br class="">> +}<br class="">> +<br class="">> bool NSAPI::isObjCTypedef(QualType T,<br class="">> StringRef name, IdentifierInfo *&II) const {<br class="">> if (!Ctx.getLangOpts().ObjC1)<br class="">><br class="">> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br class="">> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -1084,79 +1084,51 @@ static void checkConfigMacro(Preprocesso<br class="">> // not have changed.<br class="">> if (!Id->hadMacroDefinition())<br class="">> return;<br class="">> + auto *LatestLocalMD = PP.getLocalMacroDirectiveHistory(Id);<br class="">><br class="">> - // If this identifier does not currently have a macro definition,<br class="">> - // check whether it had one on the command line.<br class="">> - if (!Id->hasMacroDefinition()) {<br class="">> - MacroDirective::DefInfo LatestDef =<br class="">> - PP.getMacroDirectiveHistory(Id)->getDefinition();<br class="">> - for (MacroDirective::DefInfo Def = LatestDef; Def;<br class="">> - Def = Def.getPreviousDefinition()) {<br class="">> - FileID FID = SourceMgr.getFileID(Def.getLocation());<br class="">> - if (FID.isInvalid())<br class="">> - continue;<br class="">> -<br class="">> - // We only care about the predefines buffer.<br class="">> - if (FID != PP.getPredefinesFileID())<br class="">> - continue;<br class="">> -<br class="">> - // This macro was defined on the command line, then #undef'd later.<br class="">> - // Complain.<br class="">> - PP.Diag(ImportLoc, diag::warn_module_config_macro_undef)<br class="">> - << true << ConfigMacro << Mod->getFullModuleName();<br class="">> - if (LatestDef.isUndefined())<br class="">> - PP.Diag(LatestDef.getUndefLocation(), diag::note_module_def_undef_here)<br class="">> - << true;<br class="">> - return;<br class="">> - }<br class="">> -<br class="">> - // Okay: no definition in the predefines buffer.<br class="">> - return;<br class="">> - }<br class="">> -<br class="">> - // This identifier has a macro definition. Check whether we had a definition<br class="">> - // on the command line.<br class="">> - MacroDirective::DefInfo LatestDef =<br class="">> - PP.getMacroDirectiveHistory(Id)->getDefinition();<br class="">> - MacroDirective::DefInfo PredefinedDef;<br class="">> - for (MacroDirective::DefInfo Def = LatestDef; Def;<br class="">> - Def = Def.getPreviousDefinition()) {<br class="">> - FileID FID = SourceMgr.getFileID(Def.getLocation());<br class="">> - if (FID.isInvalid())<br class="">> - continue;<br class="">> -<br class="">> + // Find the macro definition from the command line.<br class="">> + MacroInfo *CmdLineDefinition = nullptr;<br class="">> + for (auto *MD = LatestLocalMD; MD; MD = MD->getPrevious()) {<br class="">> // We only care about the predefines buffer.<br class="">> - if (FID != PP.getPredefinesFileID())<br class="">> + FileID FID = SourceMgr.getFileID(MD->getLocation());<br class="">> + if (FID.isInvalid() || FID != PP.getPredefinesFileID())<br class="">> continue;<br class="">> -<br class="">> - PredefinedDef = Def;<br class="">> + if (auto *DMD = dyn_cast<DefMacroDirective>(MD))<br class="">> + CmdLineDefinition = DMD->getMacroInfo();<br class="">> break;<br class="">> }<br class="">><br class="">> - // If there was no definition for this macro in the predefines buffer,<br class="">> - // complain.<br class="">> - if (!PredefinedDef ||<br class="">> - (!PredefinedDef.getLocation().isValid() &&<br class="">> - PredefinedDef.getUndefLocation().isValid())) {<br class="">> + auto *CurrentDefinition = PP.getMacroInfo(Id);<br class="">> + if (CurrentDefinition == CmdLineDefinition) {<br class="">> + // Macro matches. Nothing to do.<br class="">> + } else if (!CurrentDefinition) {<br class="">> + // This macro was defined on the command line, then #undef'd later.<br class="">> + // Complain.<br class="">> + PP.Diag(ImportLoc, diag::warn_module_config_macro_undef)<br class="">> + << true << ConfigMacro << Mod->getFullModuleName();<br class="">> + auto LatestDef = LatestLocalMD->getDefinition();<br class="">> + assert(LatestDef.isUndefined() &&<br class="">> + "predefined macro went away with no #undef?");<br class="">> + PP.Diag(LatestDef.getUndefLocation(), diag::note_module_def_undef_here)<br class="">> + << true;<br class="">> + return;<br class="">> + } else if (!CmdLineDefinition) {<br class="">> + // There was no definition for this macro in the predefines buffer,<br class="">> + // but there was a local definition. Complain.<br class="">> PP.Diag(ImportLoc, diag::warn_module_config_macro_undef)<br class="">> << false << ConfigMacro << Mod->getFullModuleName();<br class="">> - PP.Diag(LatestDef.getLocation(), diag::note_module_def_undef_here)<br class="">> + PP.Diag(CurrentDefinition->getDefinitionLoc(),<br class="">> + diag::note_module_def_undef_here)<br class="">> + << false;<br class="">> + } else if (!CurrentDefinition->isIdenticalTo(*CmdLineDefinition, PP,<br class="">> + /*Syntactically=*/true)) {<br class="">> + // The macro definitions differ.<br class="">> + PP.Diag(ImportLoc, diag::warn_module_config_macro_undef)<br class="">> + << false << ConfigMacro << Mod->getFullModuleName();<br class="">> + PP.Diag(CurrentDefinition->getDefinitionLoc(),<br class="">> + diag::note_module_def_undef_here)<br class="">> << false;<br class="">> - return;<br class="">> }<br class="">> -<br class="">> - // If the current macro definition is the same as the predefined macro<br class="">> - // definition, it's okay.<br class="">> - if (LatestDef.getMacroInfo() == PredefinedDef.getMacroInfo() ||<br class="">> - LatestDef.getMacroInfo()->isIdenticalTo(*PredefinedDef.getMacroInfo(),PP,<br class="">> - /*Syntactically=*/true))<br class="">> - return;<br class="">> -<br class="">> - // The macro definitions differ.<br class="">> - PP.Diag(ImportLoc, diag::warn_module_config_macro_undef)<br class="">> - << false << ConfigMacro << Mod->getFullModuleName();<br class="">> - PP.Diag(LatestDef.getLocation(), diag::note_module_def_undef_here)<br class="">> - << false;<br class="">> }<br class="">><br class="">> /// \brief Write a new timestamp file with the given path.<br class="">><br class="">> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)<br class="">> +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -686,9 +686,9 @@ static void DoPrintMacros(Preprocessor &<br class="">> SmallVector<id_macro_pair, 128> MacrosByID;<br class="">> for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();<br class="">> I != E; ++I) {<br class="">> - if (I->first->hasMacroDefinition())<br class="">> - MacrosByID.push_back(<br class="">> - id_macro_pair(I->first, I->second.getLatest()->getMacroInfo()));<br class="">> + auto *MD = I->second.getLatest();<br class="">> + if (MD && MD->isDefined())<br class="">> + MacrosByID.push_back(id_macro_pair(I->first, MD->getMacroInfo()));<br class="">> }<br class="">> llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(), MacroIDCompare);<br class="">><br class="">><br class="">> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -18,6 +18,7 @@<br class="">> #include "clang/Lex/HeaderSearchOptions.h"<br class="">> #include "clang/Lex/LexDiagnostic.h"<br class="">> #include "clang/Lex/Lexer.h"<br class="">> +#include "clang/Lex/Preprocessor.h"<br class="">> #include "llvm/ADT/APInt.h"<br class="">> #include "llvm/ADT/Hashing.h"<br class="">> #include "llvm/ADT/SmallString.h"<br class="">> @@ -1016,7 +1017,9 @@ void HeaderSearch::MarkFileModuleHeader(<br class="">> HFI.setHeaderRole(Role);<br class="">> }<br class="">><br class="">> -bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){<br class="">> +bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,<br class="">> + const FileEntry *File,<br class="">> + bool isImport) {<br class="">> ++NumIncluded; // Count # of attempted #includes.<br class="">><br class="">> // Get information about this file.<br class="">> @@ -1041,7 +1044,7 @@ bool HeaderSearch::ShouldEnterIncludeFil<br class="">> // if the macro that guards it is defined, we know the #include has no effect.<br class="">> if (const IdentifierInfo *ControllingMacro<br class="">> = FileInfo.getControllingMacro(ExternalLookup))<br class="">> - if (ControllingMacro->hasMacroDefinition()) {<br class="">> + if (PP.isMacroDefined(ControllingMacro)) {<br class="">> ++NumMultiIncludeFileOptzn;<br class="">> return false;<br class="">> }<br class="">><br class="">> Modified: cfe/trunk/lib/Lex/MacroArgs.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/MacroArgs.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -133,12 +133,11 @@ bool MacroArgs::ArgNeedsPreexpansion(con<br class="">> // If there are no identifiers in the argument list, or if the identifiers are<br class="">> // known to not be macros, pre-expansion won't modify it.<br class="">> for (; ArgTok->isNot(tok::eof); ++ArgTok)<br class="">> - if (IdentifierInfo *II = ArgTok->getIdentifierInfo()) {<br class="">> - if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled())<br class="">> + if (IdentifierInfo *II = ArgTok->getIdentifierInfo())<br class="">> + if (II->hasMacroDefinition())<br class="">> // Return true even though the macro could be a function-like macro<br class="">> - // without a following '(' token.<br class="">> + // without a following '(' token, or could be disabled, or not visible.<br class="">> return true;<br class="">> - }<br class="">> return false;<br class="">> }<br class="">><br class="">><br class="">> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -179,11 +179,13 @@ bool Preprocessor::CheckMacroName(Token<br class="">> return Diag(MacroNameTok, diag::err_defined_macro_name);<br class="">> }<br class="">><br class="">> - if (isDefineUndef == MU_Undef && II->hasMacroDefinition() &&<br class="">> - getMacroInfo(II)->isBuiltinMacro()) {<br class="">> - // Warn if undefining "__LINE__" and other builtins, per C99 6.10.8/4<br class="">> - // and C++ [cpp.predefined]p4], but allow it as an extension.<br class="">> - Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro);<br class="">> + if (isDefineUndef == MU_Undef) {<br class="">> + auto *MI = getMacroInfo(II);<br class="">> + if (MI && MI->isBuiltinMacro()) {<br class="">> + // Warn if undefining "__LINE__" and other builtins, per C99 6.10.8/4<br class="">> + // and C++ [cpp.predefined]p4], but allow it as an extension.<br class="">> + Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro);<br class="">> + }<br class="">> }<br class="">><br class="">> // If defining/undefining reserved identifier or a keyword, we need to issue<br class="">> @@ -1292,7 +1294,7 @@ void Preprocessor::HandleMacroPublicDire<br class="">><br class="">> IdentifierInfo *II = MacroNameTok.getIdentifierInfo();<br class="">> // Okay, we finally have a valid identifier to undef.<br class="">> - MacroDirective *MD = getMacroDirective(II);<br class="">> + MacroDirective *MD = getLocalMacroDirective(II);<br class="">><br class="">> // If the macro is not defined, this is an error.<br class="">> if (!MD) {<br class="">> @@ -1319,7 +1321,7 @@ void Preprocessor::HandleMacroPrivateDir<br class="">><br class="">> IdentifierInfo *II = MacroNameTok.getIdentifierInfo();<br class="">> // Okay, we finally have a valid identifier to undef.<br class="">> - MacroDirective *MD = getMacroDirective(II);<br class="">> + MacroDirective *MD = getLocalMacroDirective(II);<br class="">><br class="">> // If the macro is not defined, this is an error.<br class="">> if (!MD) {<br class="">> @@ -1757,7 +1759,7 @@ void Preprocessor::HandleIncludeDirectiv<br class="">><br class="">> // Ask HeaderInfo if we should enter this #include file. If not, #including<br class="">> // this file will have no effect.<br class="">> - if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) {<br class="">> + if (!HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport)) {<br class="">> if (Callbacks)<br class="">> Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);<br class="">> return;<br class="">> @@ -2295,16 +2297,19 @@ void Preprocessor::HandleUndefDirective(<br class="">> // Check to see if this is the last token on the #undef line.<br class="">> CheckEndOfDirective("undef");<br class="">><br class="">> - // Okay, we finally have a valid identifier to undef.<br class="">> - MacroDirective *MD = getMacroDirective(MacroNameTok.getIdentifierInfo());<br class="">> - const MacroInfo *MI = MD ? MD->getMacroInfo() : nullptr;<br class="">> + // Okay, we have a valid identifier to undef.<br class="">> + auto *II = MacroNameTok.getIdentifierInfo();<br class="">><br class="">> // If the callbacks want to know, tell them about the macro #undef.<br class="">> // Note: no matter if the macro was defined or not.<br class="">> - if (Callbacks)<br class="">> + if (Callbacks) {<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> + MacroDirective *MD = getLocalMacroDirective(II);<br class="">> Callbacks->MacroUndefined(MacroNameTok, MD);<br class="">> + }<br class="">><br class="">> // If the macro is not defined, this is a noop undef, just return.<br class="">> + const MacroInfo *MI = getMacroInfo(II);<br class="">> if (!MI)<br class="">> return;<br class="">><br class="">> @@ -2349,8 +2354,7 @@ void Preprocessor::HandleIfdefDirective(<br class="">> CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");<br class="">><br class="">> IdentifierInfo *MII = MacroNameTok.getIdentifierInfo();<br class="">> - MacroDirective *MD = getMacroDirective(MII);<br class="">> - MacroInfo *MI = MD ? MD->getMacroInfo() : nullptr;<br class="">> + MacroInfo *MI = getMacroInfo(MII);<br class="">><br class="">> if (CurPPLexer->getConditionalStackDepth() == 0) {<br class="">> // If the start of a top-level #ifdef and if the macro is not defined,<br class="">> @@ -2369,6 +2373,8 @@ void Preprocessor::HandleIfdefDirective(<br class="">> markMacroAsUsed(MI);<br class="">><br class="">> if (Callbacks) {<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> + MacroDirective *MD = getLocalMacroDirective(MII);<br class="">> if (isIfndef)<br class="">> Callbacks->Ifndef(DirectiveTok.getLocation(), MacroNameTok, MD);<br class="">> else<br class="">><br class="">> Modified: cfe/trunk/lib/Lex/PPExpressions.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/PPExpressions.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/PPExpressions.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -108,15 +108,13 @@ static bool EvaluateDefined(PPValue &Res<br class="">><br class="">> // Otherwise, we got an identifier, is it defined to something?<br class="">> IdentifierInfo *II = PeekTok.getIdentifierInfo();<br class="">> - Result.Val = II->hasMacroDefinition();<br class="">> + Preprocessor::MacroDefinition Macro = PP.getMacroDefinition(II);<br class="">> + Result.Val = !!Macro;<br class="">> Result.Val.setIsUnsigned(false); // Result is signed intmax_t.<br class="">><br class="">> - MacroDirective *Macro = nullptr;<br class="">> // If there is a macro, mark it used.<br class="">> - if (Result.Val != 0 && ValueLive) {<br class="">> - Macro = PP.getMacroDirective(II);<br class="">> - PP.markMacroAsUsed(Macro->getMacroInfo());<br class="">> - }<br class="">> + if (Result.Val != 0 && ValueLive)<br class="">> + PP.markMacroAsUsed(Macro.getMacroInfo());<br class="">><br class="">> // Save macro token for callback.<br class="">> Token macroToken(PeekTok);<br class="">> @@ -144,10 +142,8 @@ static bool EvaluateDefined(PPValue &Res<br class="">><br class="">> // Invoke the 'defined' callback.<br class="">> if (PPCallbacks *Callbacks = PP.getPPCallbacks()) {<br class="">> - MacroDirective *MD = Macro;<br class="">> - // Pass the MacroInfo for the macro name even if the value is dead.<br class="">> - if (!MD && Result.Val != 0)<br class="">> - MD = PP.getMacroDirective(II);<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> + MacroDirective *MD = Macro.getLocalDirective();<br class="">> Callbacks->Defined(macroToken, MD,<br class="">> SourceRange(beginLoc, PeekTok.getLocation()));<br class="">> }<br class="">><br class="">> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -309,7 +309,7 @@ bool Preprocessor::HandleEndOfFile(Token<br class="">> }<br class="">> if (const IdentifierInfo *DefinedMacro =<br class="">> CurPPLexer->MIOpt.GetDefinedMacro()) {<br class="">> - if (!ControllingMacro->hasMacroDefinition() &&<br class="">> + if (!isMacroDefined(ControllingMacro) &&<br class="">> DefinedMacro != ControllingMacro &&<br class="">> HeaderInfo.FirstTimeLexingFile(FE)) {<br class="">><br class="">><br class="">> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -34,12 +34,11 @@<br class="">> using namespace clang;<br class="">><br class="">> MacroDirective *<br class="">> -Preprocessor::getMacroDirectiveHistory(const IdentifierInfo *II) const {<br class="">> - assert(II->hadMacroDefinition() && "Identifier has not been not a macro!");<br class="">> -<br class="">> +Preprocessor::getLocalMacroDirectiveHistory(const IdentifierInfo *II) const {<br class="">> + if (!II->hadMacroDefinition())<br class="">> + return nullptr;<br class="">> auto Pos = Macros.find(II);<br class="">> - assert(Pos != Macros.end() && "Identifier macro info is missing!");<br class="">> - return Pos->second.getLatest();<br class="">> + return Pos == Macros.end() ? nullptr : Pos->second.getLatest();<br class="">> }<br class="">><br class="">> void Preprocessor::appendMacroDirective(IdentifierInfo *II, MacroDirective *MD){<br class="">> @@ -54,7 +53,7 @@ void Preprocessor::appendMacroDirective(<br class="">><br class="">> // Set up the identifier as having associated macro history.<br class="">> II->setHasMacroDefinition(true);<br class="">> - if (!MD->isDefined())<br class="">> + if (!MD->isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())<br class="">> II->setHasMacroDefinition(false);<br class="">> if (II->isFromAST() && !MD->isImported())<br class="">> II->setChangedSinceDeserialization();<br class="">> @@ -69,7 +68,7 @@ void Preprocessor::setLoadedMacroDirecti<br class="">> StoredMD = MD;<br class="">> // Setup the identifier as having associated macro history.<br class="">> II->setHasMacroDefinition(true);<br class="">> - if (!MD->isDefined())<br class="">> + if (!MD->isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())<br class="">> II->setHasMacroDefinition(false);<br class="">> }<br class="">><br class="">> @@ -108,6 +107,8 @@ ModuleMacro *Preprocessor::addModuleMacr<br class="">><br class="">> // The new macro is always a leaf macro.<br class="">> LeafMacros.push_back(MM);<br class="">> + // The identifier now has defined macros (that may or may not be visible).<br class="">> + II->setHasMacroDefinition(true);<br class="">><br class="">> New = true;<br class="">> return MM;<br class="">> @@ -121,7 +122,7 @@ ModuleMacro *Preprocessor::getModuleMacr<br class="">> return ModuleMacros.FindNodeOrInsertPos(ID, InsertPos);<br class="">> }<br class="">><br class="">> -void Preprocessor::updateModuleMacroInfo(IdentifierInfo *II,<br class="">> +void Preprocessor::updateModuleMacroInfo(const IdentifierInfo *II,<br class="">> ModuleMacroInfo &Info) {<br class="">> assert(Info.ActiveModuleMacrosGeneration != MacroVisibilityGeneration &&<br class="">> "don't need to update this macro name info");<br class="">> @@ -156,14 +157,20 @@ void Preprocessor::updateModuleMacroInfo<br class="">> Worklist.push_back(O);<br class="">> }<br class="">> }<br class="">> + // Our reverse postorder walk found the macros in reverse order.<br class="">> + std::reverse(Info.ActiveModuleMacros.begin(), Info.ActiveModuleMacros.end());<br class="">><br class="">> // Determine whether the macro name is ambiguous.<br class="">> - Info.IsAmbiguous = false;<br class="">> MacroInfo *MI = nullptr;<br class="">> - bool IsSystemMacro = false;<br class="">> - if (auto *DMD = dyn_cast<DefMacroDirective>(Info.MD)) {<br class="">> - MI = DMD->getInfo();<br class="">> - IsSystemMacro = SourceMgr.isInSystemHeader(DMD->getLocation());<br class="">> + bool IsSystemMacro = true;<br class="">> + bool IsAmbiguous = false;<br class="">> + if (auto *MD = Info.MD) {<br class="">> + while (MD && isa<VisibilityMacroDirective>(MD))<br class="">> + MD = MD->getPrevious();<br class="">> + if (auto *DMD = dyn_cast_or_null<DefMacroDirective>(MD)) {<br class="">> + MI = DMD->getInfo();<br class="">> + IsSystemMacro &= SourceMgr.isInSystemHeader(DMD->getLocation());<br class="">> + }<br class="">> }<br class="">> for (auto *Active : Info.ActiveModuleMacros) {<br class="">> auto *NewMI = Active->getMacroInfo();<br class="">> @@ -177,13 +184,14 @@ void Preprocessor::updateModuleMacroInfo<br class="">> //<br class="">> // FIXME: Remove the defined-in-system-headers check. clang's limits.h<br class="">> // overrides the system limits.h's macros, so there's no conflict here.<br class="">> - IsSystemMacro &= Active->getOwningModule()->IsSystem;<br class="">> - if (MI && NewMI != MI && !IsSystemMacro &&<br class="">> - !MI->isIdenticalTo(*NewMI, *this, /*Syntactically=*/true)) {<br class="">> - Info.IsAmbiguous = true;<br class="">> - break;<br class="">> - }<br class="">> + if (MI && NewMI != MI &&<br class="">> + !MI->isIdenticalTo(*NewMI, *this, /*Syntactically=*/true))<br class="">> + IsAmbiguous = true;<br class="">> + IsSystemMacro &= Active->getOwningModule()->IsSystem ||<br class="">> + SourceMgr.isInSystemHeader(NewMI->getDefinitionLoc());<br class="">> + MI = NewMI;<br class="">> }<br class="">> + Info.IsAmbiguous = IsAmbiguous && !IsSystemMacro;<br class="">> }<br class="">><br class="">> /// RegisterBuiltinMacro - Register the specified identifier in the identifier<br class="">> @@ -270,10 +278,11 @@ static bool isTrivialSingleTokenExpansio<br class="">><br class="">> // If the identifier is a macro, and if that macro is enabled, it may be<br class="">> // expanded so it's not a trivial expansion.<br class="">> - if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled() &&<br class="">> - // Fast expanding "#define X X" is ok, because X would be disabled.<br class="">> - II != MacroIdent)<br class="">> - return false;<br class="">> + if (auto *ExpansionMI = PP.getMacroInfo(II))<br class="">> + if (PP.getMacroInfo(II)->isEnabled() &&<br class="">> + // Fast expanding "#define X X" is ok, because X would be disabled.<br class="">> + II != MacroIdent)<br class="">> + return false;<br class="">><br class="">> // If this is an object-like macro invocation, it is safe to trivially expand<br class="">> // it.<br class="">> @@ -336,10 +345,8 @@ bool Preprocessor::isNextPPTokenLParen()<br class="">> /// HandleMacroExpandedIdentifier - If an identifier token is read that is to be<br class="">> /// expanded as a macro, handle it and return the next token as 'Identifier'.<br class="">> bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,<br class="">> - MacroDirective *MD) {<br class="">> - MacroDirective::DefInfo Def = MD->getDefinition();<br class="">> - assert(Def.isValid());<br class="">> - MacroInfo *MI = Def.getMacroInfo();<br class="">> + const MacroDefinition &M) {<br class="">> + MacroInfo *MI = M.getMacroInfo();<br class="">><br class="">> // If this is a macro expansion in the "#if !defined(x)" line for the file,<br class="">> // then the macro could expand to different things in other contexts, we need<br class="">> @@ -348,7 +355,8 @@ bool Preprocessor::HandleMacroExpandedId<br class="">><br class="">> // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially.<br class="">> if (MI->isBuiltinMacro()) {<br class="">> - if (Callbacks) Callbacks->MacroExpands(Identifier, MD,<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> + if (Callbacks) Callbacks->MacroExpands(Identifier, M.getLocalDirective(),<br class="">> Identifier.getLocation(),<br class="">> /*Args=*/nullptr);<br class="">> ExpandBuiltinMacro(Identifier);<br class="">> @@ -396,10 +404,13 @@ bool Preprocessor::HandleMacroExpandedId<br class="">> // reading the function macro arguments. To ensure, in that case, that<br class="">> // MacroExpands callbacks still happen in source order, queue this<br class="">> // callback to have it happen after the function macro callback.<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> DelayedMacroExpandsCallbacks.push_back(<br class="">> - MacroExpandsInfo(Identifier, MD, ExpansionRange));<br class="">> + MacroExpandsInfo(Identifier, M.getLocalDirective(), ExpansionRange));<br class="">> } else {<br class="">> - Callbacks->MacroExpands(Identifier, MD, ExpansionRange, Args);<br class="">> + // FIXME: Tell callbacks about module macros.<br class="">> + Callbacks->MacroExpands(Identifier, M.getLocalDirective(), ExpansionRange,<br class="">> + Args);<br class="">> if (!DelayedMacroExpandsCallbacks.empty()) {<br class="">> for (unsigned i=0, e = DelayedMacroExpandsCallbacks.size(); i!=e; ++i) {<br class="">> MacroExpandsInfo &Info = DelayedMacroExpandsCallbacks[i];<br class="">> @@ -413,20 +424,16 @@ bool Preprocessor::HandleMacroExpandedId<br class="">> }<br class="">><br class="">> // If the macro definition is ambiguous, complain.<br class="">> - if (Def.getDirective()->isAmbiguous()) {<br class="">> + if (M.isAmbiguous()) {<br class="">> Diag(Identifier, diag::warn_pp_ambiguous_macro)<br class="">> << Identifier.getIdentifierInfo();<br class="">> Diag(MI->getDefinitionLoc(), diag::note_pp_ambiguous_macro_chosen)<br class="">> << Identifier.getIdentifierInfo();<br class="">> - for (MacroDirective::DefInfo PrevDef = Def.getPreviousDefinition();<br class="">> - PrevDef && !PrevDef.isUndefined();<br class="">> - PrevDef = PrevDef.getPreviousDefinition()) {<br class="">> - Diag(PrevDef.getMacroInfo()->getDefinitionLoc(),<br class="">> - diag::note_pp_ambiguous_macro_other)<br class="">> - << Identifier.getIdentifierInfo();<br class="">> - if (!PrevDef.getDirective()->isAmbiguous())<br class="">> - break;<br class="">> - }<br class="">> + M.forAllDefinitions([&](const MacroInfo *OtherMI) {<br class="">> + if (OtherMI != MI)<br class="">> + Diag(OtherMI->getDefinitionLoc(), diag::note_pp_ambiguous_macro_other)<br class="">> + << Identifier.getIdentifierInfo();<br class="">> + });<br class="">> }<br class="">><br class="">> // If we started lexing a macro, enter the macro expansion body.<br class="">><br class="">> Modified: cfe/trunk/lib/Lex/Pragma.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/Pragma.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/Pragma.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -400,7 +400,7 @@ void Preprocessor::HandlePragmaPoison(To<br class="">> if (II->isPoisoned()) continue;<br class="">><br class="">> // If this is a macro identifier, emit a warning.<br class="">> - if (II->hasMacroDefinition())<br class="">> + if (isMacroDefined(II))<br class="">> Diag(Tok, diag::pp_poisoning_existing_macro);<br class="">><br class="">> // Finally, poison it!<br class="">> @@ -590,8 +590,7 @@ void Preprocessor::HandlePragmaPopMacro(<br class="">> PragmaPushMacroInfo.find(IdentInfo);<br class="">> if (iter != PragmaPushMacroInfo.end()) {<br class="">> // Forget the MacroInfo currently associated with IdentInfo.<br class="">> - if (MacroDirective *CurrentMD = getMacroDirective(IdentInfo)) {<br class="">> - MacroInfo *MI = CurrentMD->getMacroInfo();<br class="">> + if (MacroInfo *MI = getMacroInfo(IdentInfo)) {<br class="">> if (MI->isWarnIfUnused())<br class="">> WarnUnusedMacroLocs.erase(MI->getDefinitionLoc());<br class="">> appendMacroDirective(IdentInfo, AllocateUndefMacroDirective(MessageLoc));<br class="">><br class="">> Modified: cfe/trunk/lib/Lex/Preprocessor.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Lex/Preprocessor.cpp (original)<br class="">> +++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -73,8 +73,7 @@ Preprocessor::Preprocessor(IntrusiveRefC<br class="">> ModuleImportExpectsIdentifier(false), CodeCompletionReached(0),<br class="">> MainFileDir(nullptr), SkipMainFilePreamble(0, true), CurPPLexer(nullptr),<br class="">> CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr),<br class="">> - Callbacks(nullptr), MacroVisibilityGeneration(0),<br class="">> - MacroArgCache(nullptr), Record(nullptr),<br class="">> + Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr),<br class="">> MIChainHead(nullptr), DeserialMIChainHead(nullptr) {<br class="">> OwnsHeaderSearch = OwnsHeaders;<br class="">><br class="">> @@ -108,6 +107,9 @@ Preprocessor::Preprocessor(IntrusiveRefC<br class="">><br class="">> // We haven't read anything from the external source.<br class="">> ReadMacrosFromExternalSource = false;<br class="">> + // We might already have some macros from an imported module (via a PCH or<br class="">> + // preamble) if modules is enabled.<br class="">> + MacroVisibilityGeneration = LangOpts.Modules ? 1 : 0;<br class="">><br class="">> // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.<br class="">> // This gets unpoisoned where it is allowed.<br class="">> @@ -623,8 +625,8 @@ bool Preprocessor::HandleIdentifier(Toke<br class="">> }<br class="">><br class="">> // If this is a macro to be expanded, do it.<br class="">> - if (MacroDirective *MD = getMacroDirective(&II)) {<br class="">> - MacroInfo *MI = MD->getMacroInfo();<br class="">> + if (MacroDefinition MD = getMacroDefinition(&II)) {<br class="">> + auto *MI = MD.getMacroInfo();<br class="">> if (!DisableMacroExpansion) {<br class="">> if (!Identifier.isExpandDisabled() && MI->isEnabled()) {<br class="">> // C99 6.10.3p10: If the preprocessing token immediately after the<br class="">><br class="">> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)<br class="">> +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -2017,7 +2017,7 @@ static void AddOrdinaryNameResults(Sema:<br class="">> if (SemaRef.getLangOpts().C11) {<br class="">> // _Alignof<br class="">> Builder.AddResultTypeChunk("size_t");<br class="">> - if (SemaRef.getASTContext().Idents.get("alignof").hasMacroDefinition())<br class="">> + if (SemaRef.PP.isMacroDefined("alignof"))<br class="">> Builder.AddTypedTextChunk("alignof");<br class="">> else<br class="">> Builder.AddTypedTextChunk("_Alignof");<br class="">> @@ -2085,15 +2085,14 @@ static void AddResultTypeChunk(ASTContex<br class="">> Result.getAllocator()));<br class="">> }<br class="">><br class="">> -static void MaybeAddSentinel(ASTContext &Context,<br class="">> +static void MaybeAddSentinel(Preprocessor &PP,<br class="">> const NamedDecl *FunctionOrMethod,<br class="">> CodeCompletionBuilder &Result) {<br class="">> if (SentinelAttr *Sentinel = FunctionOrMethod->getAttr<SentinelAttr>())<br class="">> if (Sentinel->getSentinel() == 0) {<br class="">> - if (Context.getLangOpts().ObjC1 &&<br class="">> - Context.Idents.get("nil").hasMacroDefinition())<br class="">> + if (PP.getLangOpts().ObjC1 && PP.isMacroDefined("nil"))<br class="">> Result.AddTextChunk(", nil");<br class="">> - else if (Context.Idents.get("NULL").hasMacroDefinition())<br class="">> + else if (PP.isMacroDefined("NULL"))<br class="">> Result.AddTextChunk(", NULL");<br class="">> else<br class="">> Result.AddTextChunk(", (void*)0");<br class="">> @@ -2117,8 +2116,7 @@ static std::string formatObjCParamQualif<br class="">> return Result;<br class="">> }<br class="">><br class="">> -static std::string FormatFunctionParameter(ASTContext &Context,<br class="">> - const PrintingPolicy &Policy,<br class="">> +static std::string FormatFunctionParameter(const PrintingPolicy &Policy,<br class="">> const ParmVarDecl *Param,<br class="">> bool SuppressName = false,<br class="">> bool SuppressBlock = false) {<br class="">> @@ -2217,7 +2215,7 @@ static std::string FormatFunctionParamet<br class="">> for (unsigned I = 0, N = Block.getNumParams(); I != N; ++I) {<br class="">> if (I)<br class="">> Params += ", ";<br class="">> - Params += FormatFunctionParameter(Context, Policy, Block.getParam(I),<br class="">> + Params += FormatFunctionParameter(Policy, Block.getParam(I),<br class="">> /*SuppressName=*/false,<br class="">> /*SuppressBlock=*/true);<br class="">><br class="">> @@ -2247,7 +2245,7 @@ static std::string FormatFunctionParamet<br class="">> }<br class="">><br class="">> /// \brief Add function parameter chunks to the given code completion string.<br class="">> -static void AddFunctionParameterChunks(ASTContext &Context,<br class="">> +static void AddFunctionParameterChunks(Preprocessor &PP,<br class="">> const PrintingPolicy &Policy,<br class="">> const FunctionDecl *Function,<br class="">> CodeCompletionBuilder &Result,<br class="">> @@ -2265,7 +2263,7 @@ static void AddFunctionParameterChunks(A<br class="">> Result.getCodeCompletionTUInfo());<br class="">> if (!FirstParameter)<br class="">> Opt.AddChunk(CodeCompletionString::CK_Comma);<br class="">> - AddFunctionParameterChunks(Context, Policy, Function, Opt, P, true);<br class="">> + AddFunctionParameterChunks(PP, Policy, Function, Opt, P, true);<br class="">> Result.AddOptionalChunk(Opt.TakeString());<br class="">> break;<br class="">> }<br class="">> @@ -2278,9 +2276,8 @@ static void AddFunctionParameterChunks(A<br class="">> InOptional = false;<br class="">><br class="">> // Format the placeholder string.<br class="">> - std::string PlaceholderStr = FormatFunctionParameter(Context, Policy,<br class="">> - Param);<br class="">> -<br class="">> + std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);<br class="">> +<br class="">> if (Function->isVariadic() && P == N - 1)<br class="">> PlaceholderStr += ", ...";<br class="">><br class="">> @@ -2295,7 +2292,7 @@ static void AddFunctionParameterChunks(A<br class="">> if (Proto->getNumParams() == 0)<br class="">> Result.AddPlaceholderChunk("...");<br class="">><br class="">> - MaybeAddSentinel(Context, Function, Result);<br class="">> + MaybeAddSentinel(PP, Function, Result);<br class="">> }<br class="">> }<br class="">><br class="">> @@ -2575,11 +2572,7 @@ CodeCompletionResult::CreateCodeCompleti<br class="">> }<br class="">><br class="">> if (Kind == RK_Macro) {<br class="">> - const MacroDirective *MD = PP.getMacroDirectiveHistory(Macro);<br class="">> - assert(MD && "Not a macro?");<br class="">> - const MacroInfo *MI = MD->getMacroInfo();<br class="">> - assert((!MD->isDefined() || MI) && "missing MacroInfo for define");<br class="">> -<br class="">> + const MacroInfo *MI = PP.getMacroInfo(Macro);<br class="">> Result.AddTypedTextChunk(<br class="">> Result.getAllocator().CopyString(Macro->getName()));<br class="">><br class="">> @@ -2654,7 +2647,7 @@ CodeCompletionResult::CreateCodeCompleti<br class="">> Ctx, Policy);<br class="">> AddTypedNameChunk(Ctx, Policy, ND, Result);<br class="">> Result.AddChunk(CodeCompletionString::CK_LeftParen);<br class="">> - AddFunctionParameterChunks(Ctx, Policy, Function, Result);<br class="">> + AddFunctionParameterChunks(PP, Policy, Function, Result);<br class="">> Result.AddChunk(CodeCompletionString::CK_RightParen);<br class="">> AddFunctionTypeQualsToCompletionString(Result, Function);<br class="">> return Result.TakeString();<br class="">> @@ -2708,7 +2701,7 @@ CodeCompletionResult::CreateCodeCompleti<br class="">><br class="">> // Add the function parameters<br class="">> Result.AddChunk(CodeCompletionString::CK_LeftParen);<br class="">> - AddFunctionParameterChunks(Ctx, Policy, Function, Result);<br class="">> + AddFunctionParameterChunks(PP, Policy, Function, Result);<br class="">> Result.AddChunk(CodeCompletionString::CK_RightParen);<br class="">> AddFunctionTypeQualsToCompletionString(Result, Function);<br class="">> return Result.TakeString();<br class="">> @@ -2769,7 +2762,7 @@ CodeCompletionResult::CreateCodeCompleti<br class="">> std::string Arg;<br class="">><br class="">> if ((*P)->getType()->isBlockPointerType() && !DeclaringEntity)<br class="">> - Arg = FormatFunctionParameter(Ctx, Policy, *P, true);<br class="">> + Arg = FormatFunctionParameter(Policy, *P, true);<br class="">> else {<br class="">> (*P)->getType().getAsStringInternal(Arg, Policy);<br class="">> Arg = "(" + formatObjCParamQualifiers((*P)->getObjCDeclQualifier())<br class="">> @@ -2800,7 +2793,7 @@ CodeCompletionResult::CreateCodeCompleti<br class="">> Result.AddPlaceholderChunk(", ...");<br class="">> }<br class="">><br class="">> - MaybeAddSentinel(Ctx, Method, Result);<br class="">> + MaybeAddSentinel(PP, Method, Result);<br class="">> }<br class="">><br class="">> return Result.TakeString();<br class="">> @@ -2854,8 +2847,7 @@ static void AddOverloadParameterChunks(A<br class="">> // Format the placeholder string.<br class="">> std::string Placeholder;<br class="">> if (Function)<br class="">> - Placeholder = FormatFunctionParameter(Context, Policy,<br class="">> - Function->getParamDecl(P));<br class="">> + Placeholder = FormatFunctionParameter(Policy, Function->getParamDecl(P));<br class="">> else<br class="">> Placeholder = Prototype->getParamType(P).getAsString(Policy);<br class="">><br class="">> @@ -3036,8 +3028,9 @@ static void AddMacroResults(Preprocessor<br class="">> for (Preprocessor::macro_iterator M = PP.macro_begin(),<br class="">> MEnd = PP.macro_end();<br class="">> M != MEnd; ++M) {<br class="">> - if (IncludeUndefined || M->first->hasMacroDefinition()) {<br class="">> - if (MacroInfo *MI = M->second.getLatest()->getMacroInfo())<br class="">> + auto MD = PP.getMacroDefinition(M->first);<br class="">> + if (IncludeUndefined || MD) {<br class="">> + if (MacroInfo *MI = MD.getMacroInfo())<br class="">> if (MI->isUsedForHeaderGuard())<br class="">> continue;<br class="">><br class="">> @@ -5122,7 +5115,7 @@ void Sema::CodeCompleteObjCPassingType(S<br class="">> // an action, e.g.,<br class="">> // IBAction)<#selector#>:(id)sender<br class="">> if (DS.getObjCDeclQualifier() == 0 && !IsParameter &&<br class="">> - Context.Idents.get("IBAction").hasMacroDefinition()) {<br class="">> + PP.isMacroDefined("IBAction")) {<br class="">> CodeCompletionBuilder Builder(Results.getAllocator(),<br class="">> Results.getCodeCompletionTUInfo(),<br class="">> CCP_CodePattern, CXAvailability_Available);<br class="">><br class="">> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br class="">> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -450,12 +450,11 @@ void Sema::DiagnoseSentinelCalls(NamedDe<br class="">> SourceLocation MissingNilLoc<br class="">> = PP.getLocForEndOfToken(sentinelExpr->getLocEnd());<br class="">> std::string NullValue;<br class="">> - if (calleeType == CT_Method &&<br class="">> - PP.getIdentifierInfo("nil")->hasMacroDefinition())<br class="">> + if (calleeType == CT_Method && PP.isMacroDefined("nil"))<br class="">> NullValue = "nil";<br class="">> else if (getLangOpts().CPlusPlus11)<br class="">> NullValue = "nullptr";<br class="">> - else if (PP.getIdentifierInfo("NULL")->hasMacroDefinition())<br class="">> + else if (PP.isMacroDefined("NULL"))<br class="">> NullValue = "NULL";<br class="">> else<br class="">> NullValue = "(void*) 0";<br class="">><br class="">> Modified: cfe/trunk/lib/Sema/SemaFixItUtils.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaFixItUtils.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaFixItUtils.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Sema/SemaFixItUtils.cpp (original)<br class="">> +++ cfe/trunk/lib/Sema/SemaFixItUtils.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -161,11 +161,8 @@ bool ConversionFixItGenerator::tryToFixC<br class="">> }<br class="">><br class="">> static bool isMacroDefined(const Sema &S, SourceLocation Loc, StringRef Name) {<br class="">> - const IdentifierInfo *II = &S.getASTContext().Idents.get(Name);<br class="">> - if (!II->hadMacroDefinition()) return false;<br class="">> -<br class="">> - MacroDirective *Macro = S.PP.getMacroDirectiveHistory(II);<br class="">> - return Macro && Macro->findDirectiveAtLoc(Loc, S.getSourceManager());<br class="">> + return (bool)S.PP.getMacroDefinitionAtLoc(&S.getASTContext().Idents.get(Name),<br class="">> + Loc);<br class="">> }<br class="">><br class="">> static std::string getScalarZeroExpressionForType(<br class="">><br class="">> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br class="">> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -1723,22 +1723,6 @@ void ASTReader::markIdentifierUpToDate(I<br class="">> IdentifierGeneration[II] = getGeneration();<br class="">> }<br class="">><br class="">> -struct ASTReader::ModuleMacroInfo {<br class="">> - ModuleMacro *MM;<br class="">> - // FIXME: Remove this.<br class="">> - ModuleFile *F;<br class="">> -<br class="">> - bool isDefine() const { return MM->getMacroInfo(); }<br class="">> -<br class="">> - ArrayRef<ModuleMacro *> getOverriddenMacros() const {<br class="">> - return MM->overrides();<br class="">> - }<br class="">> -<br class="">> - MacroDirective *import(Preprocessor &PP, SourceLocation ImportLoc) const {<br class="">> - return PP.AllocateImportedMacroDirective(MM, ImportLoc);<br class="">> - }<br class="">> -};<br class="">> -<br class="">> void ASTReader::resolvePendingMacro(IdentifierInfo *II,<br class="">> const PendingMacroInfo &PMInfo) {<br class="">> ModuleFile &M = *PMInfo.M;<br class="">> @@ -1806,19 +1790,7 @@ void ASTReader::resolvePendingMacro(Iden<br class="">><br class="">> bool Inserted = false;<br class="">> Module *Owner = getSubmodule(MMR.SubModID);<br class="">> - auto *MM = PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);<br class="">> - if (!Inserted)<br class="">> - continue;<br class="">> -<br class="">> - ModuleMacroInfo MMI = { MM, &M };<br class="">> - if (Owner->NameVisibility == Module::Hidden) {<br class="">> - // Macros in the owning module are hidden. Just remember this macro to<br class="">> - // install if we make this module visible.<br class="">> - HiddenNamesMap[Owner].HiddenMacros.insert(<br class="">> - std::make_pair(II, new (Context) ModuleMacroInfo(MMI)));<br class="">> - } else {<br class="">> - installImportedMacro(II, MMI, Owner);<br class="">> - }<br class="">> + PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);<br class="">> }<br class="">> }<br class="">><br class="">> @@ -1870,164 +1842,6 @@ void ASTReader::resolvePendingMacro(Iden<br class="">> PP.setLoadedMacroDirective(II, Latest);<br class="">> }<br class="">><br class="">> -/// \brief For the given macro definitions, check if they are both in system<br class="">> -/// modules.<br class="">> -static bool areDefinedInSystemModules(MacroInfo *PrevMI, MacroInfo *NewMI,<br class="">> - Module *NewOwner, ASTReader &Reader) {<br class="">> - assert(PrevMI && NewMI);<br class="">> - Module *PrevOwner = nullptr;<br class="">> - if (SubmoduleID PrevModID = PrevMI->getOwningModuleID())<br class="">> - PrevOwner = Reader.getSubmodule(PrevModID);<br class="">> - if (PrevOwner && PrevOwner == NewOwner)<br class="">> - return false;<br class="">> - SourceManager &SrcMgr = Reader.getSourceManager();<br class="">> - bool PrevInSystem = (PrevOwner && PrevOwner->IsSystem) ||<br class="">> - SrcMgr.isInSystemHeader(PrevMI->getDefinitionLoc());<br class="">> - bool NewInSystem = (NewOwner && NewOwner->IsSystem) ||<br class="">> - SrcMgr.isInSystemHeader(NewMI->getDefinitionLoc());<br class="">> - return PrevInSystem && NewInSystem;<br class="">> -}<br class="">> -<br class="">> -void ASTReader::removeOverriddenMacros(IdentifierInfo *II,<br class="">> - SourceLocation ImportLoc,<br class="">> - AmbiguousMacros &Ambig,<br class="">> - ArrayRef<ModuleMacro *> Overrides) {<br class="">> - for (ModuleMacro *Overridden : Overrides) {<br class="">> - Module *Owner = Overridden->getOwningModule();<br class="">> - // If this macro is not yet visible, remove it from the hidden names list.<br class="">> - // It won't be there if we're in the middle of making the owner visible.<br class="">> - auto HiddenIt = HiddenNamesMap.find(Owner);<br class="">> - if (HiddenIt != HiddenNamesMap.end()) {<br class="">> - HiddenNames &Hidden = HiddenIt->second;<br class="">> - HiddenMacrosMap::iterator HI = Hidden.HiddenMacros.find(II);<br class="">> - if (HI != Hidden.HiddenMacros.end()) {<br class="">> - // Register the macro now so we don't lose it when we re-export.<br class="">> - PP.appendMacroDirective(II, HI->second->import(PP, ImportLoc));<br class="">> -<br class="">> - auto SubOverrides = HI->second->getOverriddenMacros();<br class="">> - Hidden.HiddenMacros.erase(HI);<br class="">> - removeOverriddenMacros(II, ImportLoc, Ambig, SubOverrides);<br class="">> - }<br class="">> - }<br class="">> -<br class="">> - // If this macro is already in our list of conflicts, remove it from there.<br class="">> - Ambig.erase(<br class="">> - std::remove_if(Ambig.begin(), Ambig.end(), [&](DefMacroDirective *MD) {<br class="">> - return getSubmodule(MD->getInfo()->getOwningModuleID()) == Owner;<br class="">> - }),<br class="">> - Ambig.end());<br class="">> - }<br class="">> -}<br class="">> -<br class="">> -ASTReader::AmbiguousMacros *<br class="">> -ASTReader::removeOverriddenMacros(IdentifierInfo *II,<br class="">> - SourceLocation ImportLoc,<br class="">> - ArrayRef<ModuleMacro *> Overrides) {<br class="">> - MacroDirective *Prev = PP.getMacroDirective(II);<br class="">> - if (!Prev && Overrides.empty())<br class="">> - return nullptr;<br class="">> -<br class="">> - DefMacroDirective *PrevDef = Prev ? Prev->getDefinition().getDirective()<br class="">> - : nullptr;<br class="">> - if (PrevDef && PrevDef->isAmbiguous()) {<br class="">> - // We had a prior ambiguity. Check whether we resolve it (or make it worse).<br class="">> - AmbiguousMacros &Ambig = AmbiguousMacroDefs[II];<br class="">> - Ambig.push_back(PrevDef);<br class="">> -<br class="">> - removeOverriddenMacros(II, ImportLoc, Ambig, Overrides);<br class="">> -<br class="">> - if (!Ambig.empty())<br class="">> - return &Ambig;<br class="">> -<br class="">> - AmbiguousMacroDefs.erase(II);<br class="">> - } else {<br class="">> - // There's no ambiguity yet. Maybe we're introducing one.<br class="">> - AmbiguousMacros Ambig;<br class="">> - if (PrevDef)<br class="">> - Ambig.push_back(PrevDef);<br class="">> -<br class="">> - removeOverriddenMacros(II, ImportLoc, Ambig, Overrides);<br class="">> -<br class="">> - if (!Ambig.empty()) {<br class="">> - AmbiguousMacros &Result = AmbiguousMacroDefs[II];<br class="">> - std::swap(Result, Ambig);<br class="">> - return &Result;<br class="">> - }<br class="">> - }<br class="">> -<br class="">> - // We ended up with no ambiguity.<br class="">> - return nullptr;<br class="">> -}<br class="">> -<br class="">> -void ASTReader::installImportedMacro(IdentifierInfo *II, ModuleMacroInfo &MMI,<br class="">> - Module *Owner) {<br class="">> - assert(II && Owner);<br class="">> -<br class="">> - SourceLocation ImportLoc = Owner->MacroVisibilityLoc;<br class="">> -<br class="">> - AmbiguousMacros *Prev =<br class="">> - removeOverriddenMacros(II, ImportLoc, MMI.getOverriddenMacros());<br class="">> -<br class="">> - // Create a synthetic macro definition corresponding to the import (or null<br class="">> - // if this was an undefinition of the macro).<br class="">> - MacroDirective *Imported = MMI.import(PP, ImportLoc);<br class="">> - DefMacroDirective *MD = dyn_cast<DefMacroDirective>(Imported);<br class="">> -<br class="">> - // If there's no ambiguity, just install the macro.<br class="">> - if (!Prev) {<br class="">> - PP.appendMacroDirective(II, Imported);<br class="">> - return;<br class="">> - }<br class="">> - assert(!Prev->empty());<br class="">> -<br class="">> - if (!MD) {<br class="">> - // We imported a #undef that didn't remove all prior definitions. The most<br class="">> - // recent prior definition remains, and we install it in the place of the<br class="">> - // imported directive, as if by a local #pragma pop_macro.<br class="">> - MacroInfo *NewMI = Prev->back()->getInfo();<br class="">> - Prev->pop_back();<br class="">> - MD = PP.AllocateDefMacroDirective(NewMI, ImportLoc);<br class="">> -<br class="">> - // Install our #undef first so that we don't lose track of it. We'll replace<br class="">> - // this with whichever macro definition ends up winning.<br class="">> - PP.appendMacroDirective(II, Imported);<br class="">> - }<br class="">> -<br class="">> - // We're introducing a macro definition that creates or adds to an ambiguity.<br class="">> - // We can resolve that ambiguity if this macro is token-for-token identical to<br class="">> - // all of the existing definitions.<br class="">> - MacroInfo *NewMI = MD->getInfo();<br class="">> - assert(NewMI && "macro definition with no MacroInfo?");<br class="">> - while (!Prev->empty()) {<br class="">> - MacroInfo *PrevMI = Prev->back()->getInfo();<br class="">> - assert(PrevMI && "macro definition with no MacroInfo?");<br class="">> -<br class="">> - // Before marking the macros as ambiguous, check if this is a case where<br class="">> - // both macros are in system headers. If so, we trust that the system<br class="">> - // did not get it wrong. This also handles cases where Clang's own<br class="">> - // headers have a different spelling of certain system macros:<br class="">> - // #define LONG_MAX __LONG_MAX__ (clang's limits.h)<br class="">> - // #define LONG_MAX 0x7fffffffffffffffL (system's limits.h)<br class="">> - //<br class="">> - // FIXME: Remove the defined-in-system-headers check. clang's limits.h<br class="">> - // overrides the system limits.h's macros, so there's no conflict here.<br class="">> - if (NewMI != PrevMI &&<br class="">> - !PrevMI->isIdenticalTo(*NewMI, PP, /*Syntactically=*/true) &&<br class="">> - !areDefinedInSystemModules(PrevMI, NewMI, Owner, *this))<br class="">> - break;<br class="">> -<br class="">> - // The previous definition is the same as this one (or both are defined in<br class="">> - // system modules so we can assume they're equivalent); we don't need to<br class="">> - // track it any more.<br class="">> - Prev->pop_back();<br class="">> - }<br class="">> -<br class="">> - if (!Prev->empty())<br class="">> - MD->setAmbiguous(true);<br class="">> -<br class="">> - PP.appendMacroDirective(II, MD);<br class="">> -}<br class="">> -<br class="">> ASTReader::InputFileInfo<br class="">> ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID) {<br class="">> // Go find this input file.<br class="">> @@ -3422,7 +3236,7 @@ void ASTReader::makeNamesVisible(const H<br class="">> "nothing to make visible?");<br class="">><br class="">> // FIXME: Only do this if Owner->NameVisibility == AllVisible.<br class="">> - for (Decl *D : Names.HiddenDecls) {<br class="">> + for (Decl *D : Names) {<br class="">> bool wasHidden = D->Hidden;<br class="">> D->Hidden = false;<br class="">><br class="">> @@ -3432,9 +3246,6 @@ void ASTReader::makeNamesVisible(const H<br class="">> }<br class="">> }<br class="">> }<br class="">> -<br class="">> - for (const auto &Macro : Names.HiddenMacros)<br class="">> - installImportedMacro(Macro.first, *Macro.second, Owner);<br class="">> }<br class="">><br class="">> void ASTReader::makeModuleVisible(Module *Mod,<br class="">><br class="">> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)<br class="">> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -474,7 +474,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {<br class="">><br class="">> // Note that this declaration was hidden because its owning module is<br class="">> // not yet visible.<br class="">> - Reader.HiddenNamesMap[Owner].HiddenDecls.push_back(D);<br class="">> + Reader.HiddenNamesMap[Owner].push_back(D);<br class="">> }<br class="">> }<br class="">> }<br class="">> @@ -1402,8 +1402,8 @@ void ASTDeclReader::MergeDefinitionData(<br class="">> else {<br class="">> auto SubmoduleID = MergeDD.Definition->getOwningModuleID();<br class="">> assert(SubmoduleID && "hidden definition in no module");<br class="">> - Reader.HiddenNamesMap[Reader.getSubmodule(SubmoduleID)]<br class="">> - .HiddenDecls.push_back(DD.Definition);<br class="">> + Reader.HiddenNamesMap[Reader.getSubmodule(SubmoduleID)].push_back(<br class="">> + DD.Definition);<br class="">> }<br class="">> }<br class="">> }<br class="">> @@ -3816,7 +3816,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,<br class="">> if (Owner && Owner->NameVisibility != Module::AllVisible) {<br class="">> // If Owner is made visible at some later point, make this declaration<br class="">> // visible too.<br class="">> - Reader.HiddenNamesMap[Owner].HiddenDecls.push_back(D);<br class="">> + Reader.HiddenNamesMap[Owner].push_back(D);<br class="">> } else {<br class="">> // The declaration is now visible.<br class="">> D->Hidden = false;<br class="">><br class="">> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br class="">> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -2050,7 +2050,7 @@ void ASTWriter::WritePreprocessor(const<br class="">> // If the macro or identifier need no updates, don't write the macro history<br class="">> // for this one.<br class="">> // FIXME: Chain the macro history instead of re-writing it.<br class="">> - if (MD->isFromPCH() &&<br class="">> + if (MD && MD->isFromPCH() &&<br class="">> Name->isFromAST() && !Name->hasChangedSinceDeserialization())<br class="">> continue;<br class="">><br class="">><br class="">> Modified: cfe/trunk/test/Index/complete-macros.c<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macros.c?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macros.c?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/test/Index/complete-macros.c (original)<br class="">> +++ cfe/trunk/test/Index/complete-macros.c Wed Apr 29 18:20:19 2015<br class="">> @@ -28,7 +28,7 @@ void test_variadic() {<br class="">> // RUN: c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC0 %s<br class="">> // CHECK-CC0-NOT: FOO<br class="">> // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC1 %s<br class="">> -// CHECK-CC1: macro definition:{TypedText FOO}{LeftParen (}{Placeholder Arg1}{Comma , }{Placeholder Arg2}{RightParen )}<br class="">> +// CHECK-CC1: macro definition:{TypedText FOO} (70)<br class="">> // RUN: c-index-test -code-completion-at=%s:13:13 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s<br class="">> // RUN: c-index-test -code-completion-at=%s:14:8 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s<br class="">> // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:8 %s -I%S | FileCheck -check-prefix=CHECK-CC2 %s<br class="">><br class="">> Modified: cfe/trunk/test/Modules/macros.c<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/test/Modules/macros.c (original)<br class="">> +++ cfe/trunk/test/Modules/macros.c Wed Apr 29 18:20:19 2015<br class="">> @@ -13,6 +13,7 @@<br class="">> // expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}}<br class="">> // expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}}<br class="">> // expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}}<br class="">> +// expected-note@Inputs/macros_left.h:11{{other definition of 'LEFT_RIGHT_DIFFERENT2'}}<br class="">><br class="">> @import macros;<br class="">><br class="">><br class="">> Modified: cfe/trunk/tools/libclang/CIndex.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=236176&r1=236175&r2=236176&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=236176&r1=236175&r2=236176&view=diff</a><br class="">> ==============================================================================<br class="">> --- cfe/trunk/tools/libclang/CIndex.cpp (original)<br class="">> +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Apr 29 18:20:19 2015<br class="">> @@ -7144,7 +7144,7 @@ MacroInfo *cxindex::getMacroInfo(const I<br class="">><br class="">> ASTUnit *Unit = cxtu::getASTUnit(TU);<br class="">> Preprocessor &PP = Unit->getPreprocessor();<br class="">> - MacroDirective *MD = PP.getMacroDirectiveHistory(&II);<br class="">> + MacroDirective *MD = PP.getLocalMacroDirectiveHistory(&II);<br class="">> if (MD) {<br class="">> for (MacroDirective::DefInfo<br class="">> Def = MD->getDefinition(); Def; Def = Def.getPreviousDefinition()) {<br class="">> @@ -7201,7 +7201,7 @@ MacroDefinition *cxindex::checkForMacroI<br class="">> if (std::find(MI->arg_begin(), MI->arg_end(), &II) != MI->arg_end())<br class="">> return nullptr;<br class="">><br class="">> - MacroDirective *InnerMD = PP.getMacroDirectiveHistory(&II);<br class="">> + MacroDirective *InnerMD = PP.getLocalMacroDirectiveHistory(&II);<br class="">> if (!InnerMD)<br class="">> return nullptr;<br class="">><br class="">><br class="">><br class="">> _______________________________________________<br class="">> cfe-commits mailing list<br class="">><span class=""> </span><a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank" class="">cfe-commits@cs.uiuc.edu</a><br class="">><span class=""> </span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div></div></blockquote></div></div></div></div></blockquote></div><br class=""></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>