diff options
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
| -rw-r--r-- | lib/Frontend/FrontendAction.cpp | 62 | 
1 files changed, 34 insertions, 28 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index da4bdfabc067..a4321e720ed0 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -83,31 +83,31 @@ public:    }  }; -  /// \brief Checks deserialized declarations and emits error if a name -  /// matches one given in command-line using -error-on-deserialized-decl. -  class DeserializedDeclsChecker : public DelegatingDeserializationListener { -    ASTContext &Ctx; -    std::set<std::string> NamesToCheck; - -  public: -    DeserializedDeclsChecker(ASTContext &Ctx, -                             const std::set<std::string> &NamesToCheck,  -                             ASTDeserializationListener *Previous) -      : DelegatingDeserializationListener(Previous), -        Ctx(Ctx), NamesToCheck(NamesToCheck) { } - -    virtual void DeclRead(serialization::DeclID ID, const Decl *D) { -      if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) -        if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) { -          unsigned DiagID -            = Ctx.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, -                                                   "%0 was deserialized"); -          Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->getLocation()), DiagID) -              << ND->getNameAsString(); -        } - -      DelegatingDeserializationListener::DeclRead(ID, D); -    } +/// \brief Checks deserialized declarations and emits error if a name +/// matches one given in command-line using -error-on-deserialized-decl. +class DeserializedDeclsChecker : public DelegatingDeserializationListener { +  ASTContext &Ctx; +  std::set<std::string> NamesToCheck; + +public: +  DeserializedDeclsChecker(ASTContext &Ctx, +                           const std::set<std::string> &NamesToCheck, +                           ASTDeserializationListener *Previous) +    : DelegatingDeserializationListener(Previous), +      Ctx(Ctx), NamesToCheck(NamesToCheck) { } + +  virtual void DeclRead(serialization::DeclID ID, const Decl *D) { +    if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) +      if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) { +        unsigned DiagID +          = Ctx.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, +                                                 "%0 was deserialized"); +        Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->getLocation()), DiagID) +            << ND->getNameAsString(); +      } + +    DelegatingDeserializationListener::DeclRead(ID, D); +  }  };  } // end anonymous namespace @@ -162,6 +162,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,    setCurrentInput(Input);    setCompilerInstance(&CI); +  bool HasBegunSourceFile = false;    if (!BeginInvocation(CI))      goto failure; @@ -214,6 +215,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,      // Inform the diagnostic client we are processing a source file.      CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0); +    HasBegunSourceFile = true;      // Initialize the action.      if (!BeginSourceFileAction(CI, Input.File)) @@ -228,6 +230,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,    // Inform the diagnostic client we are processing a source file.    CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),                                             &CI.getPreprocessor()); +  HasBegunSourceFile = true;    // Initialize the action.    if (!BeginSourceFileAction(CI, Input.File)) @@ -309,13 +312,14 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,      CI.setFileManager(0);    } -  CI.getDiagnosticClient().EndSourceFile(); +  if (HasBegunSourceFile) +    CI.getDiagnosticClient().EndSourceFile();    setCurrentInput(FrontendInputFile());    setCompilerInstance(0);    return false;  } -void FrontendAction::Execute() { +bool FrontendAction::Execute() {    CompilerInstance &CI = getCompilerInstance();    // Initialize the main file entry. This needs to be delayed until after PCH @@ -325,7 +329,7 @@ void FrontendAction::Execute() {                                      getCurrentInput().IsSystem                                        ? SrcMgr::C_System                                        : SrcMgr::C_User)) -      return; +      return false;    }    if (CI.hasFrontendTimer()) { @@ -333,6 +337,8 @@ void FrontendAction::Execute() {      ExecuteAction();    }    else ExecuteAction(); + +  return true;  }  void FrontendAction::EndSourceFile() {  | 
